結果

問題 No.1632 Sorting Integers (GCD of M)
コンテスト
ユーザー nok0
提出日時 2021-07-30 21:30:35
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 612 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 275 ms
コンパイル使用メモリ 85,772 KB
実行使用メモリ 68,224 KB
最終ジャッジ日時 2026-04-05 02:51:56
合計ジャッジ時間 4,000 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 TLE * 1
other -- * 59
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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)
0