結果
問題 | No.1632 Sorting Integers (GCD of M) |
ユーザー | mkawa2 |
提出日時 | 2021-12-06 15:38:28 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 1,644 bytes |
コンパイル時間 | 175 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,264 KB |
最終ジャッジ日時 | 2024-07-07 09:18:24 |
合計ジャッジ時間 | 3,723 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 27 ms
11,136 KB |
testcase_01 | AC | 30 ms
11,136 KB |
testcase_02 | AC | 27 ms
11,008 KB |
testcase_03 | AC | 26 ms
11,136 KB |
testcase_04 | AC | 26 ms
11,136 KB |
testcase_05 | AC | 26 ms
11,136 KB |
testcase_06 | AC | 26 ms
11,008 KB |
testcase_07 | AC | 26 ms
11,136 KB |
testcase_08 | AC | 27 ms
11,136 KB |
testcase_09 | AC | 27 ms
11,136 KB |
testcase_10 | AC | 27 ms
11,008 KB |
testcase_11 | AC | 26 ms
11,136 KB |
testcase_12 | AC | 28 ms
11,136 KB |
testcase_13 | AC | 26 ms
11,136 KB |
testcase_14 | AC | 28 ms
11,008 KB |
testcase_15 | AC | 26 ms
11,136 KB |
testcase_16 | AC | 27 ms
11,008 KB |
testcase_17 | AC | 27 ms
11,136 KB |
testcase_18 | AC | 27 ms
11,136 KB |
testcase_19 | AC | 27 ms
11,136 KB |
testcase_20 | AC | 27 ms
11,008 KB |
testcase_21 | AC | 26 ms
11,136 KB |
testcase_22 | AC | 26 ms
11,136 KB |
testcase_23 | AC | 26 ms
11,136 KB |
testcase_24 | AC | 26 ms
11,136 KB |
testcase_25 | AC | 27 ms
11,008 KB |
testcase_26 | AC | 26 ms
11,136 KB |
testcase_27 | AC | 26 ms
11,136 KB |
testcase_28 | AC | 27 ms
11,136 KB |
testcase_29 | AC | 26 ms
11,136 KB |
testcase_30 | AC | 26 ms
11,008 KB |
testcase_31 | AC | 26 ms
11,136 KB |
testcase_32 | AC | 26 ms
11,008 KB |
testcase_33 | AC | 26 ms
11,136 KB |
testcase_34 | AC | 27 ms
11,136 KB |
testcase_35 | AC | 27 ms
11,008 KB |
testcase_36 | AC | 29 ms
11,136 KB |
testcase_37 | AC | 27 ms
11,136 KB |
testcase_38 | AC | 27 ms
11,136 KB |
testcase_39 | AC | 27 ms
11,136 KB |
testcase_40 | AC | 26 ms
11,008 KB |
testcase_41 | AC | 27 ms
11,136 KB |
testcase_42 | AC | 28 ms
11,008 KB |
testcase_43 | AC | 28 ms
11,136 KB |
testcase_44 | AC | 27 ms
11,008 KB |
testcase_45 | AC | 27 ms
11,136 KB |
testcase_46 | AC | 26 ms
11,136 KB |
testcase_47 | AC | 26 ms
11,136 KB |
testcase_48 | AC | 26 ms
11,136 KB |
testcase_49 | AC | 26 ms
11,136 KB |
testcase_50 | AC | 27 ms
11,008 KB |
testcase_51 | AC | 26 ms
11,136 KB |
testcase_52 | AC | 27 ms
11,264 KB |
testcase_53 | AC | 26 ms
11,008 KB |
testcase_54 | AC | 27 ms
11,008 KB |
testcase_55 | AC | 28 ms
11,008 KB |
testcase_56 | AC | 30 ms
11,008 KB |
testcase_57 | AC | 28 ms
11,136 KB |
testcase_58 | AC | 30 ms
11,136 KB |
testcase_59 | AC | 29 ms
11,136 KB |
testcase_60 | AC | 28 ms
11,136 KB |
testcase_61 | AC | 27 ms
11,136 KB |
testcase_62 | AC | 28 ms
11,136 KB |
ソースコード
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() aa = [] for a in range(1, 10): if cc[a]: aa.append(a) g = 0 for i in range(len(aa)): for j in range(i): g = gcd(g,aa[i]-aa[j]) g *= 81 s = 0 for a in range(1, 10): pw = pow(10, cc[a], g) s = (pw*s%g+(pw-1)*a%g)%g ans = gcd(g, s)//9 print(ans)