問題一覧 > 通常問題

No.395 永遠の17歳

レベル : / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 114 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 549
作問者 : koyumeishi / テスター : btk
お気に入りにしたユーザー ProblemId : 1235 / 自分の提出
問題文最終更新日: 2026-06-25 21:08:20
Forever 17 Years Old
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. Show the original
yukicoder contest 142 (順位表) の他の問題:

Problem Statement

I'm $17$ years old! (in base $X$, that is)

There is an idol whose real age is $A$ years in base-$10$ notation.
Find the smallest positive integer $X$ ($X \geq 2$) such that her age can be written as $17$ years old (in base $X$).
If no such $X$ exists, output $-1$.

Reference: https://en.wikipedia.org/wiki/Radix#In_numeral_systems

Input

$A$

The input is an integer satisfying the following.
$0 \leq A \leq 100$

Output

Find the smallest positive integer $X$ ($X \geq 2$) such that her age can be written as 17 years old (in base $X$).
If no such $X$ exists, output $-1$.

Sample

Sample 1
Input
51
Output
44

Sample 2
Input
3
Output
-1

A 3-year-old idol cannot claim to be 17 years old.

Sample 3
Input
15
Output
8

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