結果

問題 No.16 累乗の加算
ユーザー JunOnumaJunOnuma
提出日時 2017-06-14 15:29:33
言語 Python2
(2.7.18)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 333 bytes
コンパイル時間 628 ms
コンパイル使用メモリ 6,640 KB
実行使用メモリ 6,084 KB
最終ジャッジ日時 2023-09-08 12:10:15
合計ジャッジ時間 1,300 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
5,916 KB
testcase_01 AC 12 ms
5,896 KB
testcase_02 AC 13 ms
6,084 KB
testcase_03 AC 12 ms
5,920 KB
testcase_04 AC 12 ms
5,852 KB
testcase_05 AC 12 ms
5,856 KB
testcase_06 AC 12 ms
5,940 KB
testcase_07 AC 12 ms
5,936 KB
testcase_08 AC 11 ms
5,824 KB
testcase_09 AC 12 ms
5,860 KB
testcase_10 AC 11 ms
5,836 KB
testcase_11 AC 12 ms
5,820 KB
testcase_12 AC 12 ms
5,888 KB
testcase_13 AC 11 ms
5,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def func(x,a,d):
    if a == 0:
        return 1
    elif a == 1:
        return x % d
    else:
        r = func(x,a/2,d)
        r = r*r if a % 2 == 0 else r*r*(x%d)
        return r % d

x,n = map(int, raw_input().split())
l = map(int, raw_input().split())
ret = 0
for a in l:
    ret += func(x,a,(10**6+3))
print ret % (10**6+3)
0