A. Panoramix's Prediction

Codeforces
IDCF80A
Time2000ms
Memory256MB
Difficulty
brute force
English · Original
Chinese · Translation
Formal · Original
_A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not._ _The next prime number after _x_ is the **smallest** prime number greater than _x_. For example, the next prime number after 2 is 3, and the next prime number after 3 is 5. Note that there is exactly one next prime number after each number. So 5 **is not** the next prime number for 2._ One cold April morning Panoramix predicted that soon Kakofonix will break free from his straitjacket, and this will be a black day for the residents of the Gallic countryside. Panoramix's prophecy tells that if some day Asterix and Obelix beat exactly _x_ Roman soldiers, where _x_ is a prime number, and next day they beat exactly _y_ Roman soldiers, where _y_ is **the next prime number** after _x_, then it's time to wait for Armageddon, for nothing can shut Kakofonix up while he sings his infernal song. Yesterday the Gauls beat _n_ Roman soldiers and it turned out that the number _n_ was prime! Today their victims were a troop of _m_ Romans (_m_ > _n_). Determine whether the Gauls should wait for the black day after today's victory of Asterix and Obelix? ## Input The first and only input line contains two positive integers — _n_ and _m_ (2 ≤ _n_ < _m_ ≤ 50). It is guaranteed that _n_ is prime. Pretests contain all the cases with restrictions 2 ≤ _n_ < _m_ ≤ 4. ## Output Print _YES_, if _m_ is the next prime number after _n_, or _NO_ otherwise. [samples]
_质数是恰好有两个不同因数的数:1 和它本身。例如,数字 #cf_span[2]、#cf_span[7]、#cf_span[3] 是质数,而 #cf_span[1]、#cf_span[6]、#cf_span[4] 不是质数。_ _在 #cf_span[x] 之后的下一个质数是大于 #cf_span[x] 的最小质数。例如,在 #cf_span[2] 之后的下一个质数是 #cf_span[3],在 #cf_span[3] 之后的下一个质数是 #cf_span[5]。注意,每个数之后恰好存在一个下一个质数。因此,#cf_span[5] *不是* #cf_span[2] 的下一个质数。_ 一个寒冷的四月早晨,帕诺拉米克斯预言,卡科丰克斯很快将挣脱束缚,这将给高卢乡村的居民带来黑暗的一天。 帕诺拉米克斯的预言说,如果某一天阿斯特里克斯和奥贝利克斯击败了恰好 #cf_span[x] 名罗马士兵,其中 #cf_span[x] 是质数,而第二天他们击败了恰好 #cf_span[y] 名罗马士兵,其中 #cf_span[y] 是 #cf_span[x] 之后的*下一个质数*,那么就该等待末日降临了,因为当卡科丰克斯唱起他那地狱般的歌曲时,没有任何东西能让他闭嘴。 昨天,高卢人击败了 #cf_span[n] 名罗马士兵,结果发现 #cf_span[n] 是质数!今天他们的受害者是一支由 #cf_span[m] 名罗马士兵组成的部队(#cf_span[m > n])。请判断高卢人是否应在今天的胜利之后等待黑暗之日的到来? 输入仅包含一行,两个正整数 — #cf_span[n] 和 #cf_span[m](#cf_span[2 ≤ n < m ≤ 50])。保证 #cf_span[n] 是质数。 预测试包含所有满足 #cf_span[2 ≤ n < m ≤ 4] 的情况。 如果 #cf_span[m] 是 #cf_span[n] 之后的下一个质数,则输出 _YES_,否则输出 _NO_。 ## Input 输入仅包含一行,两个正整数 — #cf_span[n] 和 #cf_span[m](#cf_span[2 ≤ n < m ≤ 50])。保证 #cf_span[n] 是质数。预测试包含所有满足 #cf_span[2 ≤ n < m ≤ 4] 的情况。 ## Output 如果 #cf_span[m] 是 #cf_span[n] 之后的下一个质数,则输出 _YES_,否则输出 _NO_。 [samples]
**Definitions** Let $ n, m \in \mathbb{Z}^+ $ such that $ 2 \leq n < m \leq 50 $, and $ n $ is prime. Let $ P \subseteq \mathbb{Z}^+ $ be the set of prime numbers. **Constraints** 1. $ n \in P $ 2. $ m > n $ 3. $ m \leq 50 $ **Objective** Determine whether $ m $ is the smallest prime number strictly greater than $ n $, i.e., $$ m = \min \{ p \in P \mid p > n \} $$ Output "YES" if true, "NO" otherwise.
Samples
Input #1
3 5
Output #1
YES
Input #2
7 11
Output #2
YES
Input #3
7 9
Output #3
NO
API Response (JSON)
{
  "problem": {
    "name": "A. Panoramix's Prediction",
    "description": {
      "content": "_A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not._ _The next prime number after _x_ is the **smallest**",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF80A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "_A prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not._\n\n_The next prime number after _x_ is the **smallest**...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "_质数是恰好有两个不同因数的数:1 和它本身。例如,数字 #cf_span[2]、#cf_span[7]、#cf_span[3] 是质数,而 #cf_span[1]、#cf_span[6]、#cf_span[4] 不是质数。_\n\n_在 #cf_span[x] 之后的下一个质数是大于 #cf_span[x] 的最小质数。例如,在 #cf_span[2] 之后的下一个质数是 #cf_span[3],在...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n, m \\in \\mathbb{Z}^+ $ such that $ 2 \\leq n < m \\leq 50 $, and $ n $ is prime.\n\nLet $ P \\subseteq \\mathbb{Z}^+ $ be the set of prime numbers.\n\n**Constraints**  \n1. $ n \\in P $...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments