A. PolandBall and Hypothesis

Codeforces
IDCF755A
Time2000ms
Memory256MB
Difficulty
brute forcegraphsmathnumber theory
English · Original
Chinese · Translation
Formal · Original
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. [samples] ## 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.
PolandBall 是一个年轻聪明的球,他对质数感兴趣。他提出了以下假设:"存在一个正整数 #cf_span[n],使得对于每个正整数 #cf_span[m],数 #cf_span[n·m + 1] 都是质数"。 不幸的是,PolandBall 还缺乏经验,不知道他的假设是错误的。你能证明它错误吗?请编写一个程序,为任意 #cf_span[n] 找出一个反例。 输入中唯一的数字是 #cf_span[n] (#cf_span[1 ≤ n ≤ 1000]) —— 来自 PolandBall 假设的数。 请输出一个 #cf_span[m],使得 #cf_span[n·m + 1] 不是质数。只要输出任意满足 #cf_span[1 ≤ m ≤ 103] 的合适 #cf_span[m],你的答案就会被视为正确。保证答案存在。 质数(或称素数)是大于 #cf_span[1] 的自然数,且除了 #cf_span[1] 和它本身之外没有其他正因数。 对于第一个样例测试用例,#cf_span[3·1 + 1 = 4]。我们可以输出 #cf_span[1]。 在第二个样例测试用例中,#cf_span[4·1 + 1 = 5]。我们不能输出 #cf_span[1],因为 #cf_span[5] 是质数。但 #cf_span[m = 2] 是可以的,因为 #cf_span[4·2 + 1 = 9],而 9 不是质数。 ## Input 输入中唯一的数字是 #cf_span[n] (#cf_span[1 ≤ n ≤ 1000]) —— 来自 PolandBall 假设的数。 ## Output 请输出一个 #cf_span[m],使得 #cf_span[n·m + 1] 不是质数。只要输出任意满足 #cf_span[1 ≤ m ≤ 103] 的合适 #cf_span[m],你的答案就会被视为正确。保证答案存在。 [samples] ## Note 质数(或称素数)是大于 #cf_span[1] 的自然数,且除了 #cf_span[1] 和它本身之外没有其他正因数。对于第一个样例测试用例,#cf_span[3·1 + 1 = 4]。我们可以输出 #cf_span[1]。在第二个样例测试用例中,#cf_span[4·1 + 1 = 5]。我们不能输出 #cf_span[1],因为 #cf_span[5] 是质数。但 #cf_span[m = 2] 是可以的,因为 #cf_span[4·2 + 1 = 9],而 9 不是质数。
**Definitions** Let $ n \in \mathbb{Z} $ with $ 1 \leq n \leq 1000 $. **Objective** Find an integer $ m \in \mathbb{Z} $ such that $ 1 \leq m \leq 10^3 $ and $ nm + 1 $ is composite. **Constraint** $ nm + 1 $ is not prime.
Samples
Input #1
3
Output #1
1
Input #2
4
Output #2
2
API Response (JSON)
{
  "problem": {
    "name": "A. PolandBall and Hypothesis",
    "description": {
      "content": "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",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF755A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "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...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "PolandBall 是一个年轻聪明的球,他对质数感兴趣。他提出了以下假设:\"存在一个正整数 #cf_span[n],使得对于每个正整数 #cf_span[m],数 #cf_span[n·m + 1] 都是质数\"。\n\n不幸的是,PolandBall 还缺乏经验,不知道他的假设是错误的。你能证明它错误吗?请编写一个程序,为任意 #cf_span[n] 找出一个反例。\n\n输入中唯一的数字是 #cf_s...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z} $ with $ 1 \\leq n \\leq 1000 $.  \n\n**Objective**  \nFind an integer $ m \\in \\mathbb{Z} $ such that $ 1 \\leq m \\leq 10^3 $ and $ nm + 1 $ is composite.  \n\n**Const...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments