专栏文章

题解:P12590 橙色预警嘻

P12590题解参与者 1已保存评论 0

文章操作

快速查看文章及其快照的属性,并进行相关操作。

当前评论
0 条
当前快照
1 份
快照标识符
@mip7iyyi
此快照首次捕获于
2025/12/03 07:26
3 个月前
此快照最后确认于
2025/12/03 07:26
3 个月前
查看原文
这是一个答案填空题,可以找到答案直接输出。
求每一个 ana_n 可以用快速幂。
CPP
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

CPP
#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 分别在行数:
CPP
1 729 3229 5729 8229 10729 ...
可以发现在 3229 行以后都是依次加上 2500,所以答案就是 2500。

AC code

CPP
#include<bits/stdc++.h>
using namespace std;
int main(){
    printf("2500");
    return 0;
}
谢谢观看!

评论

0 条评论,欢迎与作者交流。

正在加载评论...