結果

問題 No.1632 Sorting Integers (GCD of M)
ユーザー sotanishysotanishy
提出日時 2021-07-30 23:22:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 853 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 71,800 KB
最終ジャッジ日時 2023-10-14 08:24:09
合計ジャッジ時間 7,342 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,000 KB
testcase_01 AC 71 ms
71,276 KB
testcase_02 AC 73 ms
71,216 KB
testcase_03 AC 73 ms
71,364 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 76 ms
71,532 KB
testcase_08 AC 73 ms
71,180 KB
testcase_09 AC 72 ms
71,416 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 73 ms
71,332 KB
testcase_14 AC 76 ms
71,352 KB
testcase_15 AC 74 ms
71,280 KB
testcase_16 WA -
testcase_17 AC 74 ms
71,284 KB
testcase_18 WA -
testcase_19 AC 73 ms
71,252 KB
testcase_20 WA -
testcase_21 AC 73 ms
71,212 KB
testcase_22 WA -
testcase_23 AC 73 ms
71,164 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 73 ms
71,312 KB
testcase_27 AC 73 ms
71,388 KB
testcase_28 AC 73 ms
71,508 KB
testcase_29 AC 74 ms
71,496 KB
testcase_30 AC 74 ms
71,604 KB
testcase_31 AC 73 ms
71,244 KB
testcase_32 AC 73 ms
71,008 KB
testcase_33 AC 73 ms
71,252 KB
testcase_34 AC 73 ms
71,312 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 74 ms
71,360 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 74 ms
71,308 KB
testcase_43 AC 72 ms
71,156 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 74 ms
71,408 KB
testcase_47 AC 74 ms
71,016 KB
testcase_48 AC 73 ms
71,612 KB
testcase_49 AC 75 ms
71,312 KB
testcase_50 AC 75 ms
71,336 KB
testcase_51 AC 75 ms
71,412 KB
testcase_52 AC 72 ms
71,528 KB
testcase_53 AC 73 ms
71,204 KB
testcase_54 AC 77 ms
71,452 KB
testcase_55 AC 74 ms
71,312 KB
testcase_56 AC 75 ms
71,576 KB
testcase_57 AC 75 ms
71,392 KB
testcase_58 AC 76 ms
71,176 KB
testcase_59 AC 73 ms
71,384 KB
testcase_60 AC 73 ms
71,544 KB
testcase_61 AC 75 ms
71,180 KB
testcase_62 AC 74 ms
71,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
import sys
input = sys.stdin.readline

def ones(N):
    return (pow(10, N, mod) - 1) * pow(9, mod-2, mod) % mod

mod = 10**9 + 7
N = int(input())
c = [0] + list(map(int, input().split()))
for d in range(1, 10):
    if c[d] == N:
        print(d * ones(N) % mod)
        exit()
ans = 0
for i in range(1, 9):
    for j in range(i + 1, 10):
        if c[i] > 0 and c[j] > 0:
            a = 10 * j + i
            b = 10 * i + j
            d = a - b
            if d % 5 == 0:
                d //= 5
            while d % 2 == 0:
                d //= 2
            ans = gcd(ans, d)

total = sum(d * c[d] for d in range(1, 10))

if total % 3 != 0:
    while ans % 3 == 0:
        ans //= 3
if total % 9 != 0 and ans % 9 == 0:
    ans //= 3
if c[2] + c[4] + c[6] + c[8] == N:
    ans *= 2
if c[4] + c[8] == N:
    ans *= 2
print(ans)
0