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. 浅谈 Swift 中的 Optionals

    input[type="date"].form-control,.input-group-sm>input[type="date"].input-grou ...

  2. js css加时间戳

    为了强制更新文件,取消浏览器缓存 <link rel="stylesheet" href="~/XXX.css?time='+new Date().getTime( ...

  3. mysql 视图,存储过程,游标,触发器,用户管理简单应用

    mysql视图——是一个虚拟的表,只包含使用时动态查询的数据 优点:重用sql语句,简化复杂的SQL操作,保护数据,可以给用户看到表的部分字段而不是全部,更改数据格式和表现形式 规则: 名称唯一,必须 ...

  4. QT添加openssl的方法

    Assuming Windows you can download its installation from Win32 OpenSSL Installation Project page. You ...

  5. 【C#】wpf查找父子节点

    原文:[C#]wpf查找父子节点 using System; using System.Collections.Generic; using System.Linq; using System.Tex ...

  6. Win8 Metro(C#)数字图像处理--2.65形态学轮廓提取算法

    原文:Win8 Metro(C#)数字图像处理--2.65形态学轮廓提取算法  [函数名称]   形态学轮廓提取函数       WriteableBitmap Morcontourextract ...

  7. ARTS 12.31 - 1.4

    Algorithm 这是一道需要用动态规划的问题.求字符串的最长回文子序列. 复习了一遍动态规划,重点是要分析出最优解所包含的子问题的最优解,把过程描述为数学公式. 题目https://leetcod ...

  8. Android零基础入门第5节:善用ADT Bundle,轻松邂逅女神

    原文:Android零基础入门第5节:善用ADT Bundle,轻松邂逅女神 在前几期中总结分享了Android的前世今生.Android 系统架构和应用组件那些事.带你一起来聊一聊Android开发 ...

  9. Android零基础入门第3节:带你一起来聊一聊Android开发环境

    原文:Android零基础入门第3节:带你一起来聊一聊Android开发环境 工欲善其事,必先利其器.Android开发人员在自己的计算机上编写和测试应用程序,然后将其部署到实际的设备上,那首先必不可 ...

  10. Android Studio 添加 Genymotion插件

    原文:Android Studio 添加 Genymotion插件 1.下载Genymotion:官网地址,必须先注册才能下载,下载带有VirtualBox的版本 2.安装:安装时会连VirtualB ...