結果
問題 | No.1632 Sorting Integers (GCD of M) |
ユーザー |
![]() |
提出日時 | 2021-12-06 11:18:47 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,574 bytes |
コンパイル時間 | 98 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-07-07 08:52:40 |
合計ジャッジ時間 | 3,219 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 49 WA * 10 |
ソースコード
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) s = 0 for a in range(1, 10): s += a//g*cc[a] if s%9 == 0: ans = g*9 elif s%3 == 0: ans = g*3 else: ans = g print(ans%md)