結果
問題 |
No.1312 Snake Eyes
|
ユーザー |
|
提出日時 | 2020-12-09 01:59:25 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 726 ms / 2,000 ms |
コード長 | 561 bytes |
コンパイル時間 | 252 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-11-30 13:01:13 |
合計ジャッジ時間 | 19,684 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 85 |
ソースコード
import math N=int(input()) div=[] for d in range(1,10**6): if N%d==0: div+=[d,N//d] ans = N + 1 for d in div: n = N // d for L in range(1,60): ok = n + 1 if L == 1 else (1+int(math.pow(n, 1/(L-1)))) ok = min(ok, n + 1) ng = d while ok - ng > 1: m = (ok + ng) // 2 if (m**L - 1) / (m - 1) >= n: ok = m else: ng = m if ok > d and (ok**L - 1) % (ok - 1) == 0 and (ok**L - 1) // (ok - 1) == n: ans = min(ans, ok) print(ans)