結果
| 問題 |
No.1632 Sorting Integers (GCD of M)
|
| コンテスト | |
| ユーザー |
hir355
|
| 提出日時 | 2021-07-30 22:50:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 922 bytes |
| コンパイル時間 | 195 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 52,352 KB |
| 最終ジャッジ日時 | 2024-09-16 02:24:41 |
| 合計ジャッジ時間 | 3,832 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 46 WA * 13 |
ソースコード
def devisors(n):
d = []
a = 1
while a * a < n:
if n % a == 0:
d.append(a)
d.append(n // a)
a += 1
if a * a == n:
d.append(a)
return d
MOD = 10 ** 9 + 7
n = int(input())
c = [0] + list(map(int, input().split()))
for i in range(10):
if c[i] == n:
print(i * (pow(10, n, MOD) - 1) * pow(9, MOD - 2, MOD) % MOD)
exit(0)
s = 0
for i in range(9):
s += i * c[i]
ans = 1
if c[4] + c[8] == n:
ans *= 4
elif c[0] + c[2] + c[4] + c[6] + c[8] == n:
ans *= 2
if c[0] + c[5] == n:
ans *= 5
if s % 9 == 0:
ans *= 9
elif s % 3 == 0:
ans *= 3
s = set(devisors(ans))
for i in range(1, 10):
for j in range(1, i):
if c[i] > 0 and c[j] > 0:
if len(s) == 0:
s = set(devisors(i * 10 + j - j * 10 - i))
else:
s &= set(devisors(i * 10 + j - j * 10 - i))
print(max(s))
hir355