結果

問題 No.1343 Dividing Digit
ユーザー Ultimate_Tea_04Ultimate_Tea_04
提出日時 2021-01-17 21:46:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 344 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 20,724 KB
最終ジャッジ日時 2024-05-07 11:14:45
合計ジャッジ時間 2,804 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,496 KB
testcase_01 AC 26 ms
10,752 KB
testcase_02 AC 26 ms
10,624 KB
testcase_03 AC 120 ms
19,956 KB
testcase_04 AC 36 ms
11,392 KB
testcase_05 AC 52 ms
13,056 KB
testcase_06 AC 44 ms
12,288 KB
testcase_07 AC 63 ms
14,324 KB
testcase_08 AC 97 ms
17,988 KB
testcase_09 AC 111 ms
18,680 KB
testcase_10 AC 39 ms
11,648 KB
testcase_11 AC 62 ms
13,568 KB
testcase_12 AC 95 ms
17,296 KB
testcase_13 AC 90 ms
16,748 KB
testcase_14 AC 40 ms
11,776 KB
testcase_15 AC 58 ms
13,440 KB
testcase_16 AC 39 ms
11,648 KB
testcase_17 AC 111 ms
18,908 KB
testcase_18 AC 119 ms
19,612 KB
testcase_19 AC 86 ms
16,768 KB
testcase_20 AC 69 ms
14,892 KB
testcase_21 AC 103 ms
18,096 KB
testcase_22 AC 104 ms
18,404 KB
testcase_23 AC 121 ms
20,724 KB
testcase_24 AC 104 ms
12,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def powf(x,n):
    if n == 0:
        return 1
    k = 1
    while n>1:
        if n%2 != 0:
            k *= x
        x *= x
        n //= 2
    return k*x

n,k = map(int,input().split())
a = list(map(int,input().split()))
s = sum(a)
ans = 0
cnt = 1
for i in range(n):
    ans += a[n-1-i]*cnt
    ans %= s
    cnt *= k
    cnt %= s
print(ans)
0