結果

問題 No.1312 Snake Eyes
ユーザー shotoyoo
提出日時 2020-12-09 00:23:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 592 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 76,032 KB
最終ジャッジ日時 2024-11-30 12:56:41
合計ジャッジ時間 8,635 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 85
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

n = int(input())
ans = float("inf")
for x in range(1,n+1):
    p = (n-x)//x
    if x>=p:
        break
    if (n-x)%x==0:
        if x<p:
            ans = min(ans, p)
    
for p in range(2, n+1):
    if p*p>n:
        break
    v = 1
    val = 0
    for i in range(100):
        val += v
        v *= p
        if val>n:
            break
        if n%val==0 and n//val<p:
            ans = min(ans, p)
if ans==float("inf"):
    ans = n+1
print(ans)
0