結果
| 問題 | No.1312 Snake Eyes |
| コンテスト | |
| ユーザー |
H20
|
| 提出日時 | 2020-12-10 10:57:12 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 999 bytes |
| 記録 | |
| コンパイル時間 | 150 ms |
| コンパイル使用メモリ | 85,364 KB |
| 実行使用メモリ | 80,972 KB |
| 最終ジャッジ日時 | 2026-04-08 06:40:01 |
| 合計ジャッジ時間 | 10,428 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 73 TLE * 1 -- * 11 |
ソースコード
#約数列挙
def make_divisors(n):
lower_divisors , upper_divisors = [], []
i = 1
while i*i < n:
if n % i == 0:
lower_divisors.append(i)
if i != n // i:
upper_divisors.append(n//i)
i += 1
return lower_divisors+upper_divisors[::-1]
#めぐる式二部探索
#参考サイト:https://aotamasaki.hatenablog.com/entry/meguru_bisect
def is_ok(arg,tar,n):
return (arg**n-1)//(arg-1) <= tar
def meguru_bisect(ng, ok, tar, n):
while (abs(ok - ng) > 1):
mid = (ok + ng) // 2
if is_ok(mid,tar,n):
ok = mid
else:
ng = mid
return ok
N = int(input())
L=make_divisors(N)
ans = N-1
if N == 1:
print(2)
exit()
if N == 2:
print(3)
exit()
for l in L:
for i in range(2,41):
temp = meguru_bisect(10**12+1, 2 ,l ,i)
if temp>N//l and (temp**i-1)//(temp-1)==l:
ans = min(temp,ans)
if temp == 1:
break
print(ans)
H20