結果

問題 No.16 累乗の加算
ユーザー HIROPON87069639
提出日時 2016-02-21 23:39:01
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 439 bytes
コンパイル時間 45 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 28,536 KB
最終ジャッジ日時 2024-09-22 12:47:47
合計ジャッジ時間 6,517 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 TLE * 1 -- * 11
権限があれば一括ダウンロードができます

ソースコード

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