time limit per test2 seconds

memory limit per test256 megabytes

inputstandard input

outputstandard output

PolandBall is a young, clever Ball. He is interested in prime numbers. He has stated a following hypothesis: “There exists such a positive integer n that for each positive integer m number n·m + 1 is a prime number”.

Unfortunately, PolandBall is not experienced yet and doesn’t know that his hypothesis is incorrect. Could you prove it wrong? Write a program that finds a counterexample for any n.

Input

The only number in the input is n (1 ≤ n ≤ 1000) — number from the PolandBall’s hypothesis.

Output

Output such m that n·m + 1 is not a prime number. Your answer will be considered correct if you output any suitable m such that 1 ≤ m ≤ 103. It is guaranteed the the answer exists.

Examples

input

3

output

1

input

4

output

2

Note

A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself.

For the first sample testcase, 3·1 + 1 = 4. We can output 1.

In the second sample testcase, 4·1 + 1 = 5. We cannot output 1 because 5 is prime. However, m = 2 is okay since 4·2 + 1 = 9, which is not a prime number.

【题目链接】:http://codeforces.com/contest/755/problem/A

【题解】



枚举m从1..1000就好;

(special way 注意到当m=n+2的时候,n*m+1=(n+1)^2,而当m=n-2的时候,n*m+1=(n-1)^2,所以对n分类讨论一下就可以了.)

代码给的是枚举的.



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int MAXN = 110; int n; bool is(int k)
{
int len = sqrt(k);
rep1(j,2,len)
if (k%j==0)
{
return false;
}
return true;
} int main()
{
//freopen("F:\\rush.txt","r",stdin);
rei(n);
rep1(m,1,1000)
{
int k = n*m+1;
//cout << k <<endl;
if (!is(k))
{
printf("%d\n",m);
return 0;
}
}
return 0;
}

【codeforces 755A】PolandBall and Hypothesis的更多相关文章

  1. 【codeforces 755B】PolandBall and Game

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  2. 【codeforces 755D】PolandBall and Polygon

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

  3. 【codeforces 755C】PolandBall and Forest

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. 【codeforces 755F】PolandBall and Gifts

    [题目链接]:http://codeforces.com/contest/755/problem/F [题意] n个人; 计划是每个人都拿一个礼物来送给一个除了自己之外的人; 且如果一个人没有送出礼物 ...

  5. 【codeforces 755E】PolandBall and White-Red graph

    [题目链接]:http://codeforces.com/contest/755/problem/E [题意] 给你n个节点; 让你在这些点之间接若干条边;构成原图(要求n个节点都联通) 然后分别求出 ...

  6. Codeforces 755A:PolandBall and Hypothesis(暴力)

    http://codeforces.com/problemset/problem/755/A 题意:给出一个n,让你找一个m使得n*m+1不是素数. 思路:暴力枚举m判断即可. #include &l ...

  7. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  8. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  9. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

随机推荐

  1. MFC CListctr显示缩略图

    我们知道通过CImageList可以让listctr显示出图片,但是添加的图片大小必须和要CImageList 创建的图片大小一致,才能显示出来.最近遇到一个需求,需要把很多大小不一的jpeg图片通过 ...

  2. vector转数组

    vector转数组 由于vector内部的数据是存放在连续的存储空间,vector转数组事实上只需要获取vector中第一个数据的地址和数据的长度即可.如果仅仅是传参,无需任何操作,直接传地址即可,如 ...

  3. ThinkPHP5.0---URL访问

    ThinkPHP 5.0 在没有启用路由的情况下典型的URL访问规则是(采用 PATH_INFO 访问地址): http://serverName/index.php(或者其它应用入口文件)/模块/控 ...

  4. Flask项目之手机端租房网站的实战开发(八)

    说明:该篇博客是博主一字一码编写的,实属不易,请尊重原创,谢谢大家! 接着上一篇博客继续往下写 :https://blog.csdn.net/qq_41782425/article/details/8 ...

  5. hunnu11550:欧拉函数

    Problem description   一个数x的欧拉函数Φ(x)定义为全部小于x的正整数中与x互质的数的数目,如小于5且和5互质的数有1.2.3.4,一共4个,故Φ(5)=4. 对于随意正整数x ...

  6. (转)30 IMP-00019: row rejected due to ORACLE error 12899

    IMP: row rejected due IMP: ORACLE error encountered ORA: value too large , maximum: )导入日志报 IMP: 由于 O ...

  7. [React] Close the menu component when click outside the menu

    Most of the time, your components respond to events that occur within the component tree by defining ...

  8. 自旋锁spinlock解析

    1 基础概念 自旋锁与相互排斥锁有点类似,仅仅是自旋锁不会引起调用者睡眠.假设自旋锁已经被别的运行单元保持.调用者就一直循环在那里看是否该自旋锁的保持者已经释放了锁."自旋"一词就 ...

  9. php课程 9-33 php文件操作里面的注意事项有哪些

    php课程 9-33 php文件操作里面的注意事项有哪些 一.总结 一句话总结:文件操作其实很简单,就是几个文件操作函数需要记一下. 1.文件函数如何使用(如何找php文件函数的资料)? 查看参考手册 ...

  10. js进阶 12-16 jquery如何实现通过点击按钮和按下组合键两种方式提交留言

    js进阶 12-16 jquery如何实现通过点击按钮和按下组合键两种方式提交留言 一.总结 一句话总结:实现按下组合键提交留言是通过给input加keydown事件,判断按键的键码来实现的. 1.如 ...