結果
| 問題 |
No.1312 Snake Eyes
|
| コンテスト | |
| ユーザー |
FromBooska
|
| 提出日時 | 2023-08-31 20:00:22 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,133 bytes |
| コンパイル時間 | 346 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 75,648 KB |
| 最終ジャッジ日時 | 2025-01-03 04:48:39 |
| 合計ジャッジ時間 | 8,831 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 43 WA * 42 |
ソースコード
# 単調性はないので二分探索は無理
# 実験するとわかるのだが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
FromBooska