結果
| 問題 | 
                            No.1312 Snake Eyes
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-12-09 08:52:54 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 441 bytes | 
| コンパイル時間 | 153 ms | 
| コンパイル使用メモリ | 12,416 KB | 
| 実行使用メモリ | 17,692 KB | 
| 最終ジャッジ日時 | 2024-09-19 01:02:21 | 
| 合計ジャッジ時間 | 9,270 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 64 WA * 9 TLE * 1 -- * 11 | 
ソースコード
from math import isqrt
N = int(input())
ans = N - 1
for i in range(2, isqrt(N)):
    if N % i:
        continue
    div = N // i
    for x in range(1, 50):
        # bisect
        l, r = 1, div
        while r - l > 1:
            m = (r + l) // 2
            if (m ** x - 1) < div * (m - 1):
                l = m
            else:
                r = m
        if (r ** x - 1) == div * (r - 1):
            ans = min(ans, r)
print(ans)