Codeforces 755A:PolandBall and Hypothesis(暴力)
http://codeforces.com/problemset/problem/755/A
题意:给出一个n,让你找一个m使得n*m+1不是素数。
思路:暴力枚举m判断即可。
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <iostream>
#include <stack>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
#define N 100010
#define INF 0x3f3f3f3f int main()
{
int n;
cin >> n;
for(int i = ; i <= ; i++) {
int num = i * n + ;
int tmp = sqrt(num);
bool flag = ;
for(int i = ; i <= tmp; i++) {
if(num % i == ) {
flag = ; break;
}
}
if(flag) {
printf("%d\n", i);
break;
}
}
return ;
}
Codeforces 755A:PolandBall and Hypothesis(暴力)的更多相关文章
- 【codeforces 755A】PolandBall and Hypothesis
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- Codeforces Gym 100015H Hidden Code 暴力
Hidden Code 题目连接: http://codeforces.com/gym/100015/attachments Description It's time to put your hac ...
- Codeforces gym 100685 A. Ariel 暴力
A. ArielTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/A Desc ...
- Codeforces Gym 100637G G. #TheDress 暴力
G. #TheDress Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100637/problem/G ...
- [ An Ac a Day ^_^ ] CodeForces 691F Couple Cover 花式暴力
Couple Cover Time Limit: 3000MS Memory Limit: 524288KB 64bit IO Format: %I64d & %I64u Descri ...
- Codeforces 626D Jerry's Protest(暴力枚举+概率)
D. Jerry's Protest time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...
- codeforces 650D D. Image Preview (暴力+二分+dp)
题目链接: http://codeforces.com/contest/651/problem/D D. Image Preview time limit per test 1 second memo ...
- Codeforces Gym 100203G Good elements 暴力乱搞
原题链接:http://codeforces.com/gym/100203/attachments/download/1702/statements.pdf 题解 考虑暴力的复杂度是O(n^3),所以 ...
- Codeforces 839D Winter is here - 暴力 - 容斥原理
Winter is here at the North and the White Walkers are close. John Snow has an army consisting of n s ...
随机推荐
- log4net使用记录
1.在程序中引用log4net.dll 2.添加-新建配置文件Log4Net.config,并在文件属性中“复制到输出目录”选中“始终复制”,文件内容如下: <?xml version=&quo ...
- Web service的学习资源
看了半天的Web service,总算是对它有了一点眉目,不枉此行:)那就整理一下吧,来日还需要用到呢! 1.什么是Web service(请看这儿). 2.Web service的开发 ...
- Delphi中流对象的应用
Delphi的流对象(TStream的派生对象)有如下读写函数: function Read(var Buffer; Count: Longint): Longint;function Write(c ...
- scons编译mongodb(vs2008版本)遇到的问题总结
OS:win7 64 boost:1.49 mongodb:2.4.6(推荐64位版本,当然如果你系统是32位的,只能使用32的版本了) IDE:vs2008(2010的同学请跳过吧,因为官网提供的就 ...
- .NET重思(二)接口和抽象类的取舍
不得不说,接口和抽象类好像啊~两者都不可以实例化,并且未实现的部分都是由派生类实现的. 他们主要有这么个区别: (1)抽象类的派生类可以是派生类,换言之,抽象成员在派生类中不一定完全实现,而接口要求其 ...
- Delphi 10.2 非官方补丁合集
Delphi 10.2 非官方补丁合集http://blog.qdac.cc/?p=4485 FMXObject和TFORM的释放都变成异步了.虽然能保证是在主线程中释放,但是Windows部分的线程 ...
- 可以用GetObjectProp来获取对象的属性
原来可以用GetObjectProp来获取对象的属性,还有这用法,哈哈哈哈…… var SL: TStrings; UseDBTools: Boolean;begin SL := nil; if Me ...
- 使用百度网盘+Git,把版本控制托管到云端,附精彩评论
http://www.cnblogs.com/vajoy/p/3929675.html 我试过多个这种双向同步的网盘,在网络状况不好.系统卡顿以及某些程序BUG的情况下,同步会有错乱现象,尤其是多个电 ...
- 使用VS将 XML/Json 转为Model Class文件
环境: VS2015 Win10 XML例子: <OTA_GetRerStatusRQ EchoToken=" B3BB9248255BD851AC94" UserNam ...
- Codility---BinaryGap
Task description A binary gap within a positive integer N is any maximal sequence of consecutive zer ...