結果
問題 | No.1632 Sorting Integers (GCD of M) |
ユーザー | mkawa2 |
提出日時 | 2021-07-30 21:58:09 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,146 bytes |
コンパイル時間 | 168 ms |
コンパイル使用メモリ | 82,816 KB |
実行使用メモリ | 52,864 KB |
最終ジャッジ日時 | 2024-09-16 00:07:38 |
合計ジャッジ時間 | 4,440 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
52,480 KB |
testcase_01 | AC | 41 ms
52,736 KB |
testcase_02 | AC | 41 ms
52,480 KB |
testcase_03 | AC | 41 ms
52,480 KB |
testcase_04 | AC | 41 ms
52,224 KB |
testcase_05 | AC | 41 ms
52,352 KB |
testcase_06 | AC | 41 ms
51,968 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 41 ms
52,224 KB |
testcase_11 | AC | 41 ms
52,224 KB |
testcase_12 | AC | 41 ms
52,224 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 41 ms
52,224 KB |
testcase_17 | AC | 41 ms
52,352 KB |
testcase_18 | AC | 41 ms
52,352 KB |
testcase_19 | WA | - |
testcase_20 | AC | 41 ms
52,224 KB |
testcase_21 | WA | - |
testcase_22 | AC | 41 ms
52,480 KB |
testcase_23 | AC | 41 ms
52,224 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 41 ms
52,480 KB |
testcase_27 | AC | 42 ms
52,352 KB |
testcase_28 | AC | 42 ms
51,968 KB |
testcase_29 | AC | 42 ms
52,096 KB |
testcase_30 | AC | 41 ms
52,480 KB |
testcase_31 | AC | 41 ms
51,968 KB |
testcase_32 | AC | 42 ms
51,968 KB |
testcase_33 | AC | 41 ms
52,352 KB |
testcase_34 | WA | - |
testcase_35 | AC | 41 ms
51,968 KB |
testcase_36 | AC | 42 ms
52,224 KB |
testcase_37 | AC | 41 ms
52,352 KB |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | AC | 42 ms
52,352 KB |
testcase_41 | AC | 41 ms
51,968 KB |
testcase_42 | AC | 42 ms
52,224 KB |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | AC | 42 ms
52,096 KB |
testcase_47 | AC | 42 ms
52,352 KB |
testcase_48 | AC | 41 ms
52,352 KB |
testcase_49 | AC | 42 ms
51,968 KB |
testcase_50 | AC | 41 ms
51,968 KB |
testcase_51 | AC | 42 ms
51,968 KB |
testcase_52 | AC | 42 ms
52,352 KB |
testcase_53 | AC | 42 ms
52,096 KB |
testcase_54 | AC | 41 ms
52,352 KB |
testcase_55 | AC | 42 ms
52,224 KB |
testcase_56 | AC | 42 ms
51,968 KB |
testcase_57 | AC | 42 ms
52,096 KB |
testcase_58 | AC | 42 ms
52,352 KB |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
ソースコード
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 LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] 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 = 10**16 # md = 998244353 md = 10**9+7 from itertools import permutations from math import gcd n = II() ac = LI() if n < 8: aa = [] for a, c in enumerate(ac, 1): aa += [str(a)]*c ans = 0 for dd in permutations(aa): cur = int("".join(dd)) ans = gcd(ans, cur) print(ans) exit() aa, cc = [], [] for a, c in enumerate(ac, 1): if c: aa.append(a) cc.append(c) g = 0 for a in aa: g = gcd(g, a) r = 0 for a, c in zip(aa, cc): r += a*c%9 r %= 9 if r == 0: g *= 9 elif r%3 == 0: g *= 3 print(g)