結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,420 KB
testcase_01 AC 76 ms
71,300 KB
testcase_02 AC 75 ms
71,348 KB
testcase_03 AC 75 ms
71,484 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 79 ms
71,420 KB
testcase_08 AC 78 ms
71,520 KB
testcase_09 AC 78 ms
71,708 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 78 ms
71,696 KB
testcase_14 AC 77 ms
71,388 KB
testcase_15 AC 76 ms
71,480 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 76 ms
71,340 KB
testcase_20 WA -
testcase_21 AC 78 ms
71,256 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 77 ms
71,692 KB
testcase_27 AC 78 ms
71,484 KB
testcase_28 AC 76 ms
71,428 KB
testcase_29 AC 75 ms
71,732 KB
testcase_30 AC 77 ms
71,532 KB
testcase_31 AC 76 ms
71,696 KB
testcase_32 AC 78 ms
71,260 KB
testcase_33 WA -
testcase_34 AC 78 ms
71,692 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 79 ms
71,196 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 77 ms
71,144 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 75 ms
71,344 KB
testcase_47 AC 77 ms
71,512 KB
testcase_48 AC 78 ms
71,552 KB
testcase_49 AC 78 ms
71,476 KB
testcase_50 AC 77 ms
71,144 KB
testcase_51 AC 78 ms
71,092 KB
testcase_52 AC 79 ms
71,364 KB
testcase_53 AC 80 ms
71,312 KB
testcase_54 AC 78 ms
71,356 KB
testcase_55 AC 79 ms
71,476 KB
testcase_56 AC 77 ms
71,368 KB
testcase_57 AC 78 ms
71,376 KB
testcase_58 AC 75 ms
71,492 KB
testcase_59 AC 76 ms
71,484 KB
testcase_60 AC 78 ms
71,328 KB
testcase_61 AC 78 ms
71,152 KB
testcase_62 AC 75 ms
71,352 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
            ans = gcd(ans, a - b)
total = sum(d * c[d] for d in range(1, 10))
if total % 9 != 0 and ans % 9 == 0:
    ans //= 3
if total % 3 != 0 and ans % 3 == 0:
    ans //= 3
if ans % 5 == 0:
    ans //= 5
if c[8] != N and ans % 8 == 0:
    ans //= 2
if c[4] + c[8] != N and ans % 4 == 0:
    ans //= 2
if c[2] + c[4] + c[6] + c[8] != N and ans % 2 == 0:
    ans //= 2
print(ans)
0