結果
問題 |
No.1632 Sorting Integers (GCD of M)
|
ユーザー |
![]() |
提出日時 | 2021-07-30 22:45:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 932 bytes |
コンパイル時間 | 211 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 52,480 KB |
最終ジャッジ日時 | 2024-09-16 02:06:34 |
合計ジャッジ時間 | 4,312 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 WA * 28 |
ソースコード
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 = list(map(int, input().split())) for i in range(9): if c[i] == n: print((i + 1) * (pow(10, n, MOD) - 1) * pow(9, MOD - 2, MOD) % MOD) exit(0) s = 0 for i in range(9): s += (i + 1) * 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(i): if c[i - 1] > 0 and c[j - 1] > 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))