結果

問題 No.1632 Sorting Integers (GCD of M)
ユーザー mkawa2mkawa2
提出日時 2021-12-06 15:34:00
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 1,567 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-07-07 09:18:11
合計ジャッジ時間 4,076 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 49 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = 18446744073709551615
inf = 4294967295
md = 10**9+7
# md = 998244353

from itertools import permutations
from math import gcd
from random import randrange

# def solve(aa):
#     s = sum(aa)
#
#     g = 0
#     for dd in permutations(aa):
#         a = sum(d*10**i for i, d in enumerate(dd))
#         g = gcd(g, a)
#
#     if s%9 == 0:
#         ans = 9
#     elif s%3 == 0:
#         ans = 3
#     else:
#         ans = 1
#     if g != ans:
#         print(g, ans, s, aa)
#
# for n in range(2,9):
#     for _ in range(10):
#         aa = [randrange(1, 10) for _ in range(n)]
#         solve(aa)

n = II()
cc = [0]+LI()

if cc.count(0) == 9:
    for a in range(1, 10):
        if cc[a]:
            ans = (pow(10, cc[a], md)-1)*pow(9, md-2, md)%md*a%md
            print(ans)
            exit()

g = 0
for a in range(1, 10):
    if cc[a]: g = gcd(g, a)
g *= 81

s = 0
for a in range(1, 10):
    c = cc[a]
    pw = pow(10, c, g)
    s = (pw*s%g+(pw-1)*a%g)%g

ans = gcd(g, s)//9
print(ans)
0