結果

問題 No.16 累乗の加算
コンテスト
ユーザー koyopro
提出日時 2015-09-20 14:42:57
言語 PyPy2
(7.3.20)
結果
AC  
実行時間 82 ms / 5,000 ms
コード長 528 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 466 ms
コンパイル使用メモリ 77,712 KB
最終ジャッジ日時 2025-12-03 17:08:51
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# -*- coding: utf-8 -*-

# x N
# a1 a2 … aN

x, N = map(int, raw_input().split())

mod = 1000003
mods = {}

powx2 = [x]
k = 0
border = 1
while 100000000 >= border:
    powx2.append(powx2[k] ** 2 % mod)
    k += 1
    border *= 2

a = map(int, raw_input().split())

def powx(a):
    totalmod = 1
    for i in xrange(len(powx2)-1, -1, -1):
        b = 2 ** i
        if a >= b:
            totalmod *= powx2[i]
            a -= b
    return totalmod

total = 0
for i in xrange(N):
    total += powx(a[i])

print total % 1000003
0