主页
搜索
最近更新
数据统计
申请密钥
系统公告
1
/
1
请查看完所有公告
题解:P8790 [蓝桥杯 2022 国 C] 填空问题
最后更新于 2025-07-31 10:49:23
作者
qkj_qwq
分类
题解
题解
P8790
复制 Markdown
查看原文
删除文章
更新内容
## 试题 A 找规律。模拟斐波那契数列,每次都对 $10$ 取模,取个位输出。 :::info[代码] ```cpp #include<bits/stdc++.h> #define int long long using namespace std; signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int a=0,b=1,c; cout<<"1 "; for(int i=2;i<=600;i++) { cout<<(c=(a+b)%10)<<' '; a=b%10;b=c%10; if(i%60==0)cout<<'\n'; } return 0; } ``` ::: 输出: ```plain 1 1 2 3 5 8 3 1 4 5 9 4 3 7 0 7 7 4 1 5 6 1 7 8 5 3 8 1 9 0 9 9 8 7 5 2 7 9 6 5 1 6 7 3 0 3 3 6 9 5 4 9 3 2 5 7 2 9 1 0 1 1 2 3 5 8 3 1 4 5 9 4 3 7 0 7 7 4 1 5 6 1 7 8 5 3 8 1 9 0 9 9 8 7 5 2 7 9 6 5 1 6 7 3 0 3 3 6 9 5 4 9 3 2 5 7 2 9 1 0 1 1 2 3 5 8 3 1 4 5 9 4 3 7 0 7 7 4 1 5 6 1 7 8 5 3 8 1 9 0 9 9 8 7 5 2 7 9 6 5 1 6 7 3 0 3 3 6 9 5 4 9 3 2 5 7 2 9 1 0 1 1 2 3 5 8 3 1 4 5 9 4 3 7 0 7 7 4 1 5 6 1 7 8 5 3 8 1 9 0 9 9 8 7 5 2 7 9 6 5 1 6 7 3 0 3 3 6 9 5 4 9 3 2 5 7 2 9 1 0 1 1 2 3 5 8 3 1 4 5 9 4 3 7 0 7 7 4 1 5 6 1 7 8 5 3 8 1 9 0 9 9 8 7 5 2 7 9 6 5 1 6 7 3 0 3 3 6 9 5 4 9 3 2 5 7 2 9 1 0 1 1 2 3 5 8 3 1 4 5 9 4 3 7 0 7 7 4 1 5 6 1 7 8 5 3 8 1 9 0 9 9 8 7 5 2 7 9 6 5 1 6 7 3 0 3 3 6 9 5 4 9 3 2 5 7 2 9 1 0 1 1 2 3 5 8 3 1 4 5 9 4 3 7 0 7 7 4 1 5 6 1 7 8 5 3 8 1 9 0 9 9 8 7 5 2 7 9 6 5 1 6 7 3 0 3 3 6 9 5 4 9 3 2 5 7 2 9 1 0 1 1 2 3 5 8 3 1 4 5 9 4 3 7 0 7 7 4 1 5 6 1 7 8 5 3 8 1 9 0 9 9 8 7 5 2 7 9 6 5 1 6 7 3 0 3 3 6 9 5 4 9 3 2 5 7 2 9 1 0 1 1 2 3 5 8 3 1 4 5 9 4 3 7 0 7 7 4 1 5 6 1 7 8 5 3 8 1 9 0 9 9 8 7 5 2 7 9 6 5 1 6 7 3 0 3 3 6 9 5 4 9 3 2 5 7 2 9 1 0 1 1 2 3 5 8 3 1 4 5 9 4 3 7 0 7 7 4 1 5 6 1 7 8 5 3 8 1 9 0 9 9 8 7 5 2 7 9 6 5 1 6 7 3 0 3 3 6 9 5 4 9 3 2 5 7 2 9 1 0 ``` 可以发现,$60$ 个数为一次循环,且每一次循环存在 $8$ 个 $7$。那么,答案就是:$202202011200\div60\times8=26960268160$ ## 试题 B 直接暴力判断质数。反正没有时间限制。~~我运行了 $12.16$ 秒~~ :::info[暴力代码] ```cpp #include<bits/stdc++.h> #define int long long using namespace std; bool ss(int n) { if(n<2)return 0; if(n==2)return 1; if(n%2==0)return 0; for(int i=3;i*i<=n;i+=2) if(n%i==0)return 0; return 1; } signed main() { freopen("primes.txt","r",stdin); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,s=0; while(cin>>n)if(ss(n))s++; cout<<s; return 0; } ``` ::: 答案是 $342693$。
正在渲染内容...
点赞
0
收藏
0