結果

問題 No.1343 Dividing Digit
ユーザー KoDKoD
提出日時 2021-01-15 16:29:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 338 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 20,548 KB
最終ジャッジ日時 2024-05-04 17:37:03
合計ジャッジ時間 2,937 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,752 KB
testcase_01 AC 27 ms
10,752 KB
testcase_02 AC 27 ms
10,752 KB
testcase_03 AC 113 ms
19,952 KB
testcase_04 AC 34 ms
11,520 KB
testcase_05 AC 48 ms
13,312 KB
testcase_06 AC 40 ms
12,288 KB
testcase_07 AC 57 ms
14,448 KB
testcase_08 AC 94 ms
18,240 KB
testcase_09 AC 99 ms
18,928 KB
testcase_10 AC 36 ms
12,032 KB
testcase_11 AC 55 ms
13,696 KB
testcase_12 AC 87 ms
17,292 KB
testcase_13 AC 81 ms
16,872 KB
testcase_14 AC 36 ms
11,904 KB
testcase_15 AC 53 ms
13,568 KB
testcase_16 AC 37 ms
12,032 KB
testcase_17 AC 99 ms
18,836 KB
testcase_18 AC 111 ms
19,988 KB
testcase_19 AC 88 ms
16,944 KB
testcase_20 AC 66 ms
14,760 KB
testcase_21 AC 95 ms
18,336 KB
testcase_22 AC 95 ms
18,400 KB
testcase_23 AC 110 ms
20,548 KB
testcase_24 AC 94 ms
12,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
assert(1 <= N and N <= 100000)
assert(2 <= K and K <= 10000)

A = list(map(int, input().split()))
A.reverse()
assert(len(A) == N)
assert(A[N - 1] != 0)

mod = sum(A)
digit = 1
ans = 0

for x in A:
    assert(0 <= x and x < K)
    ans += digit * x
    ans %= mod
    digit *= K
    digit %= mod

print(ans)
0