結果

問題 No.1632 Sorting Integers (GCD of M)
ユーザー sotanishysotanishy
提出日時 2021-07-30 23:36:31
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,056 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 86,876 KB
実行使用メモリ 78,944 KB
最終ジャッジ日時 2023-10-14 08:40:59
合計ジャッジ時間 8,101 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,248 KB
testcase_01 AC 72 ms
71,388 KB
testcase_02 AC 74 ms
71,312 KB
testcase_03 AC 74 ms
71,344 KB
testcase_04 AC 77 ms
71,348 KB
testcase_05 AC 74 ms
71,288 KB
testcase_06 AC 72 ms
71,340 KB
testcase_07 RE -
testcase_08 WA -
testcase_09 RE -
testcase_10 AC 72 ms
71,224 KB
testcase_11 AC 71 ms
71,196 KB
testcase_12 AC 74 ms
71,300 KB
testcase_13 WA -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 75 ms
71,440 KB
testcase_17 AC 73 ms
71,140 KB
testcase_18 AC 72 ms
71,528 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 WA -
testcase_23 AC 73 ms
71,348 KB
testcase_24 AC 71 ms
71,200 KB
testcase_25 AC 73 ms
71,496 KB
testcase_26 AC 73 ms
71,180 KB
testcase_27 RE -
testcase_28 WA -
testcase_29 RE -
testcase_30 AC 73 ms
71,360 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 AC 72 ms
71,284 KB
testcase_34 AC 75 ms
71,200 KB
testcase_35 AC 74 ms
71,400 KB
testcase_36 RE -
testcase_37 AC 74 ms
71,580 KB
testcase_38 AC 74 ms
71,528 KB
testcase_39 AC 77 ms
71,220 KB
testcase_40 AC 74 ms
71,196 KB
testcase_41 AC 74 ms
71,440 KB
testcase_42 AC 73 ms
71,324 KB
testcase_43 AC 75 ms
71,360 KB
testcase_44 AC 78 ms
71,412 KB
testcase_45 AC 72 ms
71,384 KB
testcase_46 RE -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 AC 75 ms
71,336 KB
testcase_51 AC 71 ms
71,364 KB
testcase_52 AC 73 ms
71,176 KB
testcase_53 AC 70 ms
71,376 KB
testcase_54 AC 72 ms
71,316 KB
testcase_55 AC 73 ms
71,380 KB
testcase_56 AC 82 ms
71,212 KB
testcase_57 AC 74 ms
71,536 KB
testcase_58 AC 72 ms
71,196 KB
testcase_59 AC 73 ms
71,420 KB
testcase_60 AC 73 ms
71,380 KB
testcase_61 AC 75 ms
71,432 KB
testcase_62 AC 71 ms
71,312 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 = 1
total = sum(d * c[d] for d in range(1, 10))
if c[2] + c[4] + c[6] + c[8] == N:
    ans *= 2
if c[4] + c[8] == N:
    ans *= 2
if total % 3 == 0:
    ans *= 3
if total % 9 == 0:
    ans *= 3
# check divisibility by 27
s = 0
for d in range(1, 10):
    q, r = divmod(c[d], 3)
    s += d * 111 * q
    c[d] = r
s += int(''.join(str(d) * c[d] for d in range(1, 10)))
if s % 27 == 0:
    ans *= 3
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 % 7 == 0:
                d //= 7
            if d % 5 == 0:
                d //= 5
            while d % 2 == 0:
                d //= 2
            ans = gcd(ans, d)
print(ans)
0