結果

問題 No.1312 Snake Eyes
ユーザー lemondolemondo
提出日時 2020-12-13 20:15:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 882 ms / 2,000 ms
コード長 921 bytes
コンパイル時間 502 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 78,572 KB
最終ジャッジ日時 2023-08-20 11:25:31
合計ジャッジ時間 12,333 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,476 KB
testcase_01 AC 76 ms
71,240 KB
testcase_02 AC 80 ms
71,096 KB
testcase_03 AC 73 ms
71,224 KB
testcase_04 AC 76 ms
71,528 KB
testcase_05 AC 76 ms
71,368 KB
testcase_06 AC 75 ms
71,136 KB
testcase_07 AC 75 ms
71,468 KB
testcase_08 AC 76 ms
71,432 KB
testcase_09 AC 74 ms
71,460 KB
testcase_10 AC 74 ms
71,164 KB
testcase_11 AC 76 ms
71,452 KB
testcase_12 AC 77 ms
71,248 KB
testcase_13 AC 77 ms
71,464 KB
testcase_14 AC 76 ms
71,256 KB
testcase_15 AC 78 ms
71,436 KB
testcase_16 AC 75 ms
71,336 KB
testcase_17 AC 75 ms
71,160 KB
testcase_18 AC 77 ms
71,376 KB
testcase_19 AC 77 ms
71,304 KB
testcase_20 AC 74 ms
71,432 KB
testcase_21 AC 74 ms
71,304 KB
testcase_22 AC 75 ms
71,292 KB
testcase_23 AC 82 ms
75,392 KB
testcase_24 AC 80 ms
75,328 KB
testcase_25 AC 79 ms
75,372 KB
testcase_26 AC 80 ms
75,212 KB
testcase_27 AC 78 ms
75,392 KB
testcase_28 AC 80 ms
75,300 KB
testcase_29 AC 80 ms
75,440 KB
testcase_30 AC 78 ms
75,220 KB
testcase_31 AC 77 ms
75,388 KB
testcase_32 AC 79 ms
75,444 KB
testcase_33 AC 75 ms
71,524 KB
testcase_34 AC 77 ms
75,396 KB
testcase_35 AC 78 ms
75,368 KB
testcase_36 AC 80 ms
75,176 KB
testcase_37 AC 79 ms
75,384 KB
testcase_38 AC 82 ms
75,564 KB
testcase_39 AC 81 ms
75,380 KB
testcase_40 AC 82 ms
75,328 KB
testcase_41 AC 86 ms
75,372 KB
testcase_42 AC 82 ms
75,480 KB
testcase_43 AC 80 ms
75,308 KB
testcase_44 AC 78 ms
75,356 KB
testcase_45 AC 81 ms
75,356 KB
testcase_46 AC 82 ms
75,292 KB
testcase_47 AC 80 ms
75,364 KB
testcase_48 AC 205 ms
76,264 KB
testcase_49 AC 151 ms
75,556 KB
testcase_50 AC 110 ms
75,500 KB
testcase_51 AC 99 ms
75,252 KB
testcase_52 AC 127 ms
75,260 KB
testcase_53 AC 138 ms
75,540 KB
testcase_54 AC 122 ms
75,456 KB
testcase_55 AC 103 ms
75,440 KB
testcase_56 AC 137 ms
76,452 KB
testcase_57 AC 107 ms
75,404 KB
testcase_58 AC 138 ms
75,500 KB
testcase_59 AC 102 ms
75,600 KB
testcase_60 AC 101 ms
75,492 KB
testcase_61 AC 135 ms
75,628 KB
testcase_62 AC 108 ms
75,500 KB
testcase_63 AC 81 ms
75,424 KB
testcase_64 AC 82 ms
75,328 KB
testcase_65 AC 83 ms
75,432 KB
testcase_66 AC 79 ms
75,400 KB
testcase_67 AC 76 ms
71,312 KB
testcase_68 AC 79 ms
75,328 KB
testcase_69 AC 80 ms
75,188 KB
testcase_70 AC 145 ms
76,084 KB
testcase_71 AC 105 ms
75,812 KB
testcase_72 AC 83 ms
75,780 KB
testcase_73 AC 78 ms
75,400 KB
testcase_74 AC 79 ms
75,668 KB
testcase_75 AC 81 ms
75,256 KB
testcase_76 AC 882 ms
78,572 KB
testcase_77 AC 115 ms
75,188 KB
testcase_78 AC 112 ms
75,256 KB
testcase_79 AC 116 ms
76,504 KB
testcase_80 AC 118 ms
76,224 KB
testcase_81 AC 122 ms
75,364 KB
testcase_82 AC 189 ms
76,356 KB
testcase_83 AC 202 ms
76,468 KB
testcase_84 AC 109 ms
75,428 KB
testcase_85 AC 135 ms
76,068 KB
testcase_86 AC 182 ms
76,088 KB
testcase_87 AC 97 ms
75,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return list(map(int, input().split()))
sys.setrecursionlimit(10**9)

N = int(input())

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]

candidates = make_divisors(N)
candidates.sort()
lis = set()
if N==1:
    print(2)
    exit()
elif N==2:
    print(3)
    exit()

for first in candidates:
    koho = make_divisors(N//first-1)
    for k in koho:
        lis.add(k)
lis = list(lis)
lis.sort()

for c in lis[1:]:
    base = N
    lis = []
    while base>0:
        if lis and base%c!=lis[-1]:
            break
        lis.append(base%c)
        base //= c
    if base==0:
        print(c)
        exit()
0