755A PolandBall and Hypothesis
来源:互联网 发布:伴奏升降调软件 编辑:程序博客网 时间:2024/05/16 14:53
题目链接:
http://codeforces.com/problemset/problem/755/A
题解:
本题的数据的范围比较小,直接暴力判断是不是质数的方法也能够过,本来以为会超时的。
代码:
#include <cmath>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;#define met(a,b) memset(a,b,sizeof(a))#define inf 0x3f3f3f3ftypedef long long ll;int prime(int num){ int m=sqrt(num); for(int i=2;i<=m;i++) if(num%m==0) return false; return true;}int main(){ int n; while(cin>>n) { for(int i=1;i<=1e3;i++) { int m=i*n+1; if(!prime(m)) { cout<<i<<endl; break; } } }}
0 0
- 755A PolandBall and Hypothesis
- A. PolandBall and Hypothesis
- 【codeforces 755A】PolandBall and Hypothesis
- Codefoeces 755A-PolandBall and Hypothesis
- 文章标题 CoderForces 755A : PolandBall and Hypothesis(水)
- codefors755A. PolandBall and Hypothesis(打表+二分)
- 8VC Venture Cup 2017 - Elimination Round A. PolandBall and Hypothesis【水题】
- CodeForces 755APolandBall and Hypothesis
- 755B PolandBall and Game
- 【codeforces 755B】PolandBall and Game
- 【codeforces 755C】PolandBall and Forest
- 【codeforces 755D】PolandBall and Polygon
- codeforces-755-B PolandBall and Game
- Codeforces 755-B. PolandBall and Game(贪心)
- 【Codeforces 755 B PolandBall and Game】
- Codeforces 755B-PolandBall and Game
- Codeforces 755C-PolandBall and Forest
- Codeforces 755D-PolandBall and Polygon
- 解决xmind打不开的方法有哪些
- C#如何获取指定周的日期范围
- c与c++直接排序算法
- CCPC 2016安徽大学站 I 朋友 hdu 5969
- 关于设置Nginx与vsftpd时遇到的问题总结...每天基本都会遇到问题..一点一点总结吧
- 755A PolandBall and Hypothesis
- 【Inno Setup】常量
- JAVA增删改查代码
- 解决Genymotion安装软件事显示"此应用与您的手机不兼容"
- python 代码提示 'ascii' codec can't encode characters
- Java实现MySQL数据库备份
- 如何切换SVN账号
- 子网掩码 与 网关(路由器)
- Hello World程序背后的故事解密(二)——程序之生