結果

問題 No.1312 Snake Eyes
ユーザー 👑 SPD_9X2
提出日時 2025-07-17 01:21:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 546 bytes
コンパイル時間 383 ms
コンパイル使用メモリ 82,612 KB
実行使用メモリ 61,588 KB
最終ジャッジ日時 2025-07-17 01:21:42
合計ジャッジ時間 8,222 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 66 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

https://yukicoder.me/problems/no/1312

√までみればok?

それ以上は
p*x + x = N
(p+1) * x = N

を満たす最小のp

"""

import sys
from sys import stdin


N = int(input())

for p in range(2,10**6+1):

    n = N

    rem = n % p
    flag = True

    while n:
        if n % p != rem:
            flag = False
            break
        n //= p

    if flag:
        print (p)
        sys.exit()

for x in range(10**6,0,-1):
    if x*x > N and N % x == 0:
        pp = N // x
        print (pp-1)
        sys.exit()

print (N-1)
0