結果

問題 No.16 累乗の加算
ユーザー nbisconbisco
提出日時 2016-04-13 22:43:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 333 ms / 5,000 ms
コード長 371 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 10,700 KB
実行使用メモリ 47,408 KB
最終ジャッジ日時 2023-09-08 11:57:47
合計ジャッジ時間 4,059 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 333 ms
47,408 KB
testcase_01 AC 319 ms
47,252 KB
testcase_02 AC 69 ms
14,556 KB
testcase_03 AC 168 ms
27,532 KB
testcase_04 AC 173 ms
27,664 KB
testcase_05 AC 173 ms
27,648 KB
testcase_06 AC 321 ms
47,180 KB
testcase_07 AC 171 ms
27,852 KB
testcase_08 AC 173 ms
27,596 KB
testcase_09 AC 172 ms
27,844 KB
testcase_10 AC 320 ms
47,360 KB
testcase_11 AC 68 ms
14,520 KB
testcase_12 AC 327 ms
47,292 KB
testcase_13 AC 16 ms
7,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
#fileencoding: utf-8

x, _ = [int(i) for i in input().strip().split(" ")]
mod = 1000003
tmp = 1
count = 0
memo = []
memo.append(1)
while True:
    tmp = (tmp * x) % mod
    count += 1
    if tmp == 1:
        break
    memo.append(tmp)

ans = 0
for i in input().strip().split(" "):
    a = int(i)%count
    ans += memo[a]
    ans %= mod
print(ans)
0