問題一覧 > 通常問題

No.358 Mo~tto! Kadomatsu Sequence

レベル : / AI推定難易度 : 204 / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 114 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 379
作問者 : koyumeishi / テスター : 🐬hec
お気に入りにしたユーザー ProblemId : 1025 / 自分の提出
問題文最終更新日: 2026-06-26 00:49:54
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder 門松コンテスト (順位表) の他の問題:

Problem Statement

A Kadomatsu sequence is a sequence $A_1, A_2, A_3$ of $3$ elements that satisfies the following 2 conditions.

  • $A_1, A_2, A_3$ are all distinct
  • Among the $3$ elements, $A_2$ is the largest, or $A_2$ is the smallest

You are given a sequence $A = A_1, A_2, A_3$ of $3$ elements.
For the sequence $A$ and a positive integer $p(1 \leq p)$, define the sequence $B_p$ as follows.

  • ${B_p} = (A_1\mod p) , (A_2\mod p) , (A_3\mod p)$
    Note: $x \mod y$ is the remainder when $x$ is divided by $y$.
Output the number of positive integers $p$ for which $B_p$ is a Kadomatsu sequence. If there are infinitely many, output "INF".

Input

$A_1$ $A_2$ $A_3$

All inputs are integers and satisfy the following constraints.
$1 \leq A_i \leq 1000 $

Output

Output the number of positive integers $p$ for which $B_p$ is a Kadomatsu sequence. If there are infinitely many, output "INF".

Sample

Sample 1
Input
5 6 7
Output
3

$B_3 = 2,0,1$
$B_6 = 5,0,1$
$B_7 = 5,6,0$
are Kadomatsu sequences, so the answer is 3.

Sample 2
Input
5 1 4
Output
INF

Apparently there are infinitely many.

Sample 3
Input
10 20 30
Output
16

Sample 4
Input
114 514 114
Output
0

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。