結果

問題 No.1343 Dividing Digit
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2021-01-16 14:38:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 355 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 10,704 KB
実行使用メモリ 18,968 KB
最終ジャッジ日時 2023-08-18 11:48:16
合計ジャッジ時間 2,561 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,900 KB
testcase_01 AC 15 ms
7,824 KB
testcase_02 AC 15 ms
7,812 KB
testcase_03 AC 65 ms
18,068 KB
testcase_04 AC 21 ms
9,096 KB
testcase_05 AC 30 ms
11,052 KB
testcase_06 AC 24 ms
9,896 KB
testcase_07 AC 35 ms
11,792 KB
testcase_08 AC 57 ms
16,484 KB
testcase_09 AC 62 ms
17,096 KB
testcase_10 AC 22 ms
9,536 KB
testcase_11 AC 33 ms
11,760 KB
testcase_12 AC 52 ms
15,728 KB
testcase_13 AC 49 ms
15,408 KB
testcase_14 AC 22 ms
9,420 KB
testcase_15 AC 32 ms
11,500 KB
testcase_16 AC 22 ms
9,548 KB
testcase_17 AC 60 ms
17,064 KB
testcase_18 AC 65 ms
18,136 KB
testcase_19 AC 49 ms
15,428 KB
testcase_20 AC 39 ms
12,704 KB
testcase_21 AC 58 ms
16,932 KB
testcase_22 AC 59 ms
16,956 KB
testcase_23 AC 68 ms
18,968 KB
testcase_24 AC 53 ms
9,812 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