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(暴力)的更多相关文章

  1. 【codeforces 755A】PolandBall and Hypothesis

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  2. Codeforces Gym 100015H Hidden Code 暴力

    Hidden Code 题目连接: http://codeforces.com/gym/100015/attachments Description It's time to put your hac ...

  3. Codeforces gym 100685 A. Ariel 暴力

    A. ArielTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/A Desc ...

  4. Codeforces Gym 100637G G. #TheDress 暴力

    G. #TheDress Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100637/problem/G ...

  5. [ An Ac a Day ^_^ ] CodeForces 691F Couple Cover 花式暴力

    Couple Cover Time Limit: 3000MS   Memory Limit: 524288KB   64bit IO Format: %I64d & %I64u Descri ...

  6. Codeforces 626D Jerry's Protest(暴力枚举+概率)

    D. Jerry's Protest time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...

  7. codeforces 650D D. Image Preview (暴力+二分+dp)

    题目链接: http://codeforces.com/contest/651/problem/D D. Image Preview time limit per test 1 second memo ...

  8. Codeforces Gym 100203G Good elements 暴力乱搞

    原题链接:http://codeforces.com/gym/100203/attachments/download/1702/statements.pdf 题解 考虑暴力的复杂度是O(n^3),所以 ...

  9. 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 ...

随机推荐

  1. .NET 上传并解析CSV文件存库

    1.前端: 放置浏览按钮 <div class="row inner_table text-center"> <input id="fileId&quo ...

  2. jquery动态创建小广告

    <!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...

  3. 如何获取app配置文件内容

    App.config: <appSettings> <add key="FCPConnection" value="Data Source=192.16 ...

  4. c# SQLHelper总汇

    /// <summary> /// The SqlHelper class is intended to encapsulate high performance, /// scalabl ...

  5. 【全面解禁!真正的Expression Blend实战开发技巧】序章

    原文:[全面解禁!真正的Expression Blend实战开发技巧]序章 从silverlight2开始我也和大家一样一直在跟随微软的脚步,从sl2~sl4一步一步过来,总结了不少心得体会.由于各种 ...

  6. Have You Tried Delphi on Amazon Linux? (就是AWS用的Linux)

    The new Delphi Linux compiler enables customers to take new or existing Windows server applications ...

  7. ef 查询总结

    1.Linq 查询两张表:a表和b表,要得到的数据是a表数据b表没有 例如:a表有5条数据1,2,3,4,5:b表有2条数据1,3:那么就用dataGridView1输出2,4,5:link语句要怎么 ...

  8. 基于Monte Carlo方法的2048 A.I.

    2048 A.I. 在 stackoverflow 上有个讨论:http://stackoverflow.com/questions/22342854/what-is-the-optimal-algo ...

  9. 星星的模块封装类 IDSStarsScoreView

    1 IDSStarsScoreView 的实现效果     2 类的封装方法:   <声明文件>   // //  IDSStarsScoreView.h //  Near // //  ...

  10. HTTP Post之multipart/form-data和application/x-www-form-urlencoded

    关于HttpPost,有这样两种可Post的数据载体,分别是MultipartEntity和UrlEncodedFormEntity,对这两者的共性和异性做如下解释和备忘: 共性: 1.都属于HTTP ...