結果

問題 No.1312 Snake Eyes
ユーザー FromBooskaFromBooska
提出日時 2023-08-31 20:00:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,133 bytes
コンパイル時間 560 ms
コンパイル使用メモリ 86,832 KB
実行使用メモリ 78,744 KB
最終ジャッジ日時 2023-08-31 20:00:37
合計ジャッジ時間 13,977 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
70,856 KB
testcase_01 AC 71 ms
71,260 KB
testcase_02 AC 68 ms
71,232 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 69 ms
71,136 KB
testcase_06 AC 67 ms
71,264 KB
testcase_07 AC 69 ms
70,916 KB
testcase_08 AC 67 ms
71,128 KB
testcase_09 AC 67 ms
71,020 KB
testcase_10 AC 70 ms
71,128 KB
testcase_11 AC 71 ms
71,108 KB
testcase_12 AC 71 ms
71,232 KB
testcase_13 AC 70 ms
70,916 KB
testcase_14 AC 76 ms
71,320 KB
testcase_15 AC 67 ms
71,232 KB
testcase_16 AC 69 ms
71,208 KB
testcase_17 AC 68 ms
71,368 KB
testcase_18 AC 68 ms
71,132 KB
testcase_19 AC 72 ms
70,920 KB
testcase_20 WA -
testcase_21 AC 69 ms
70,912 KB
testcase_22 AC 71 ms
71,176 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 87 ms
75,104 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 70 ms
70,856 KB
testcase_34 WA -
testcase_35 AC 70 ms
75,084 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 74 ms
75,276 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 73 ms
75,140 KB
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 AC 94 ms
75,176 KB
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 AC 75 ms
75,060 KB
testcase_65 AC 77 ms
75,160 KB
testcase_66 WA -
testcase_67 AC 70 ms
71,320 KB
testcase_68 AC 76 ms
75,224 KB
testcase_69 AC 75 ms
75,440 KB
testcase_70 AC 133 ms
75,292 KB
testcase_71 AC 99 ms
75,452 KB
testcase_72 AC 77 ms
75,516 KB
testcase_73 AC 73 ms
75,208 KB
testcase_74 AC 79 ms
75,212 KB
testcase_75 AC 73 ms
75,440 KB
testcase_76 WA -
testcase_77 AC 103 ms
75,264 KB
testcase_78 WA -
testcase_79 AC 100 ms
75,416 KB
testcase_80 AC 108 ms
76,432 KB
testcase_81 AC 110 ms
75,340 KB
testcase_82 AC 177 ms
75,988 KB
testcase_83 WA -
testcase_84 AC 105 ms
75,328 KB
testcase_85 AC 125 ms
75,632 KB
testcase_86 AC 182 ms
75,384 KB
testcase_87 AC 88 ms
75,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 単調性はないので二分探索は無理
# 実験するとわかるのだがNの約数dに対して、d-1
# さらにd-1の約数、がpになりうる

def base_n(num_10,n):
    str_n = ''
    while num_10:
        if num_10%n>=10:
            return -1
        str_n += str(num_10%n)
        num_10 //= n
    return int(str_n[::-1])

def 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]

N = int(input())
p_candidates = set()
N_divs = divisors(N)
for d in N_divs:
    p_candidates.add(d-1)
    d1_divs = set(divisors(d-1))
    p_candidates |= d1_divs
p_candidates.discard(0)
p_candidates.discard(1)
p_candidates = sorted(list(p_candidates))
#print(p_candidates)
for p in p_candidates:
    calc = base_n(N, p)
    if calc == -1:
        continue
    S = set()
    for c in str(calc):
        S.add(c)
    #print('p', p, 'calc', calc, 'S', S)
    if len(S)==1:
        print(p)
        break
0