题解:P12590 橙色预警嘻
这是一个答案填空题,可以找到答案直接输出。
求每一个
int qpow(int x, int q)
{
int ret = 1;
while (q)
{
if (q & 1)
ret = (ret * x) % mod;
x *= x;
x %= mod;
q >>= 1;
}
return ret;
}
可以生成出 100000 个数找规律。
code
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5;//先生成 100000 个。
const int mod = 1e5;
int a[N];
int qpow(int x, int q)
{
int ret = 1;
while (q)
{
if (q & 1)
ret = (ret * x) % mod;
x *= x;
x %= mod;
q >>= 1;
}
return ret;
}
signed main()
{
#if !defined(ONLINE_JUDGE)
freopen("1.in", "r", stdin);
freopen("1.out", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
for (int i = 1; i <= N; i++)
{
a[i] = qpow(3, i) + qpow(5, i);
a[i] %= mod;//求每一个a[i]。
cout << a[i] << endl;
}
return 0;
}
最后输出 1.out 可以看到第一个数 8 分别在行数:
1 729 3229 5729 8229 10729 ...
可以发现在 3229 行以后都是依次加上 2500,所以答案就是 2500。
AC code
#include<bits/stdc++.h>
using namespace std;
int main(){
printf("2500");
return 0;
}
谢谢观看!