# 第十四届蓝桥杯三月真题刷题训练——第 8 天（3.11）

Think_bird 2023-03-10 23:03:28

## 分数

``````#include<bits/stdc++.h>

using namespace std;

int main()
{
long long a = pow(2, 19);
cout << a * 2 - 1 << "/" << a;

return 0;
}``````

## 回文日期

``````#include<bits/stdc++.h>

using namespace std;
int a[4];

int main()
{
int n, mn = INF, minAB = INF;
cin >> n;
for(a[0] = 1; a[0] <= 9; a[0] ++ )
for(a[1] = 0; a[1] <= 9; a[1] ++ )
for(a[2] = 0; a[2] <= 9; a[2] ++ )
for(a[3] = 0; a[3] <= 9; a[3] ++ )
{
int k = a[0] * 10000001 + a[1] * 1000010 + a[2] * 100100 + a[3] * 11000, mn = a[3] * 10 + a[2], day = a[1] * 10 + a[0], year = a[0] * 1000 + a[1] * 100 + a[2] * 10 + a[3];
if(mn <= 12 && mn > 0)
{
if((mn == 1 || mn == 3 || mn == 5 || mn == 7 || mn == 8 || mn == 10 || mn == 12) && day > 31) continue;
if(mn == 2 && (year % 400 == 0 || (year % 100 == 0 && year % 4 == 0)))
{if(day > 29) continue;}
else if(day > 28) continue;
if((mn == 4 || mn == 6 || mn == 9 || mn == 11) && day > 30) continue;
}
else continue;

if(k > n)
{
mn = min(k, mn);
if(a[2] == a[0] && a[1] == a[3]) minAB = min(minAB, k);
}
}
cout << mn << '\n' << minAB;
return 0;
}``````

...全文
43 1 打赏 收藏 举报

1 条回复

Think_bird 03-10
• 打赏
• 举报

``````
```c++
#include <bits/stdc++.h>
using namespace std;
long long f[1000000];
long long n,m,p,sum;
int main()
{
cin>>n>>m>>p;
f[1]=1;
sum=1;
for(int i=2;i<=n;i++){
f[i]=f[i-1]+f[i-2];
sum+=f[i];
}
if(m>n){
for(int i=n+1;i<=m;i++){
f[i]=f[i-1]+f[i-2];
sum+=f[i];
}
}
cout<<sum%f[m]%p;
return 0;
}

``````

```

3.2w+

2023-03-10 23:03

刷题！