結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,456 KB
testcase_01 AC 74 ms
71,460 KB
testcase_02 AC 71 ms
71,240 KB
testcase_03 AC 72 ms
71,428 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 72 ms
71,368 KB
testcase_08 AC 73 ms
71,264 KB
testcase_09 AC 73 ms
71,196 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 73 ms
71,688 KB
testcase_14 AC 72 ms
71,360 KB
testcase_15 AC 72 ms
71,404 KB
testcase_16 WA -
testcase_17 AC 73 ms
71,300 KB
testcase_18 WA -
testcase_19 AC 71 ms
71,336 KB
testcase_20 WA -
testcase_21 AC 73 ms
71,152 KB
testcase_22 WA -
testcase_23 AC 72 ms
71,296 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 72 ms
71,288 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 72 ms
71,540 KB
testcase_31 AC 75 ms
71,716 KB
testcase_32 AC 74 ms
71,144 KB
testcase_33 AC 72 ms
71,292 KB
testcase_34 AC 74 ms
71,296 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 71 ms
71,340 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 72 ms
71,508 KB
testcase_43 AC 74 ms
71,300 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 75 ms
71,596 KB
testcase_47 AC 73 ms
71,528 KB
testcase_48 AC 72 ms
71,548 KB
testcase_49 AC 73 ms
71,568 KB
testcase_50 AC 72 ms
71,416 KB
testcase_51 AC 80 ms
71,460 KB
testcase_52 AC 72 ms
71,476 KB
testcase_53 AC 71 ms
71,400 KB
testcase_54 AC 74 ms
71,352 KB
testcase_55 AC 75 ms
71,260 KB
testcase_56 AC 74 ms
71,336 KB
testcase_57 AC 75 ms
71,452 KB
testcase_58 AC 73 ms
71,324 KB
testcase_59 AC 74 ms
71,348 KB
testcase_60 AC 73 ms
71,376 KB
testcase_61 AC 74 ms
71,276 KB
testcase_62 AC 73 ms
71,660 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
            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 ans % 5 == 0:
    ans //= 5
if any(c[2*i+1] != 0 for i in range(5)):
    while ans % 2 == 0:
        ans //= 2
print(ans)
0