计蒜客ACM ICPC 2017 Warmup Contest 9--I题-Older Brother
来源:互联网 发布:网络文字录入员 编辑:程序博客网 时间:2024/06/07 15:28
- 2000ms
- 65536K
Your older brother is an amateur mathematician with lots of experience. However, his memory is very bad. He recently got interested in linear algebra over finite fields, but he does not remember exactly which finite fields exist. For you, this is an easy question: a finite field of order q exists if and only if q is a prime power, that is, q = pk holds for some prime number pand some integer k ≥ 1. Furthermore, in that case the field is unique (up to isomorphism).
The conversation with your brother went something like this:
Input
The input consists of one integer q, satisfying 1 ≤ q ≤ 109.
Output
Output “yes” if there exists a finite field of order q. Otherwise, output “no”.
样例输入1
1
样例输出1
no
样例输入2
37
样例输出2
yes
样例输入3
65536
样例输出3
yes
#include<iostream>#include<algorithm>#include<cstdio>using namespace std;int q;bool isprime[10000000];void f(){isprime[0]=false,isprime[1]=false;for(int i=2;i<10000000;i++) isprime[i]=true;for(int i=2;i<10000000;i++){if(isprime[i]){for(int k=2;k*i<10000000;k++) isprime[k*i]=false;}}}int main(){f();while(scanf("%d",&q)!=EOF){bool flag=false;for(int i=2;i<10000000;i++){if(isprime[i]==0) continue;int k=1;while(1){k*=i;if(k==q){printf("yes\n");flag=true;break;}if(k>q) break;}if(flag) break;}if(!flag) printf("no\n");}return 0;}
阅读全文
0 0
- 计蒜客ACM ICPC 2017 Warmup Contest 9--I题-Older Brother
- 计蒜客ACM ICPC 2017 Warmup Contest 9--I题-Sticky Situation
- 计蒜客ACM ICPC 2017 Warmup Contest 9--C题
- 计蒜客 ACM-ICPC 2017 Warmup Contest 12
- 计蒜客 Bridge Automation(ACM ICPC 2017 Warmup Contest 9)
- 计蒜客 Charles in Charge(ACM ICPC 2017 Warmup Contest 9)
- 计蒜客ACM ICPC 2017 Warmup Contest 9--B题-Battle Simulation
- 计蒜客 ACM ICPC 2017 Warmup Contest 1 G Game Rank
- ACM ICPC 2017 Warmup Contest 1
- ACM ICPC 2017 Warmup Contest 5
- ACM ICPC 2017 Warmup Contest 6 G
- ACM ICPC 2017 Warmup Contest 1 F. Fleecing the Raffle
- ACM ICPC 2017 Warmup Contest 1 (NCPC 2016)
- ACM ICPC 2017 Warmup Contest 4(ACM Northeastern European Regional Contest,Northern Subregion 2015)
- ACM ICPC 2017 Warmup Contest 6(ACM Google Cup 2011 Invitational Programming Contest)
- ACM ICPC 2017 Warmup Contest 2(ACM Northeastern European Regional Contest,Northern Subregion 2016)
- ACM ICPC 2017 Warmup Contest 8(ACM PolyU International Invitation Contest)
- ACM ICPC 2017 Warmup Contest 1(Nordic Collegiate Programming Contest 2016)
- CodeVS 1183 SPFA+二分答案 解题报告
- 递归知识
- 左值与右值
- Java中继承和多态,重写与重载的区别
- 线性表及其链式表示
- 计蒜客ACM ICPC 2017 Warmup Contest 9--I题-Older Brother
- NBSI 安装问题
- Can the Production Network Be the Testbed?
- python-单例模式的实现
- phpStorm 2017.2 输入法不跟随
- 左值引用和右值引用
- 给定两个整数A和B,其表示形式是:从个位开始,每三位数用逗号","隔开。 现在请计算A+B的结果,并以正常形式输出。
- Google 投资 Lyft 背后、AlphaGo Zero 人工智能威胁论?
- 16进制转换方法 Java