結果

問題 No.16 累乗の加算
ユーザー HIROPON87069639HIROPON87069639
提出日時 2016-02-21 23:39:01
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 439 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 7,072 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-23 19:02:06
合計ジャッジ時間 7,096 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,468 KB
testcase_01 AC 11 ms
6,408 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
def calc(x, n):
    flag = 1
    if n == 0:
        return 1
    p = 1
    while flag == 1:
        nn = n // 2
        mm = n % 2
        p *= x ** mm
        if nn == 0:
            flag = 0
        else:
            x *= x
            n = nn
    return p % 1000003


x, N = map(int, raw_input().split())
n = map(int, raw_input().split())
tot = 0
for i in range(0, N):
    tot += calc(x, n[i]) % 1000003
print tot
0