結果

問題 No.1343 Dividing Digit
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2021-01-16 14:38:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 355 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 20,428 KB
最終ジャッジ日時 2024-05-05 17:08:02
合計ジャッジ時間 2,384 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,752 KB
testcase_01 AC 25 ms
10,752 KB
testcase_02 AC 26 ms
10,624 KB
testcase_03 AC 80 ms
19,308 KB
testcase_04 AC 31 ms
11,520 KB
testcase_05 AC 40 ms
13,312 KB
testcase_06 AC 35 ms
12,288 KB
testcase_07 AC 46 ms
14,068 KB
testcase_08 AC 69 ms
18,024 KB
testcase_09 AC 81 ms
18,424 KB
testcase_10 AC 34 ms
12,032 KB
testcase_11 AC 45 ms
13,696 KB
testcase_12 AC 65 ms
17,336 KB
testcase_13 AC 63 ms
16,792 KB
testcase_14 AC 33 ms
11,776 KB
testcase_15 AC 45 ms
13,440 KB
testcase_16 AC 36 ms
11,904 KB
testcase_17 AC 81 ms
18,320 KB
testcase_18 AC 84 ms
19,096 KB
testcase_19 AC 66 ms
16,944 KB
testcase_20 AC 53 ms
14,720 KB
testcase_21 AC 74 ms
18,360 KB
testcase_22 AC 74 ms
18,316 KB
testcase_23 AC 86 ms
20,428 KB
testcase_24 AC 68 ms
12,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
def getlist(): return list(map(int, input().split()))
        
def main():
    n,k = getlist()
    a = getlist()
    total = sum(a)
    ans = 0
    K = 1
    for i in range(n-1,-1,-1):
        ans += a[i] * K
        K *= k
        K %= total
        ans %= total
    print(ans)

if __name__ == '__main__':
    main()
0