結果
問題 |
No.1632 Sorting Integers (GCD of M)
|
ユーザー |
![]() |
提出日時 | 2021-07-30 21:30:35 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 612 bytes |
コンパイル時間 | 263 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 63,488 KB |
最終ジャッジ日時 | 2024-09-15 23:06:13 |
合計ジャッジ時間 | 3,949 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 TLE * 1 |
other | -- * 59 |
ソースコード
from math import gcd mod = 10 ** 9 + 7 n = int(input()) c = list(map(int, input().split())) g = 0 for i in range(9): for j in range(i + 1, 9): if c[i] and c[j]: g = gcd(g, 9 * (j - i)) res = 0 if g == 0: x = 0 for i in range(9): for j in range(c[i]): x *= 10 x += i + 1 x %= mod print(x) exit() for k in range(1, g + 1): if g % k: continue x = 0 for i in range(9): for j in range(c[i]): x *= 10 x += i + 1 x %= k if x == 0: res = k print(res % mod)