結果

問題 No.16 累乗の加算
ユーザー gahougahou
提出日時 2016-11-02 14:45:25
言語 Python2
(2.7.18)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 338 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 6,600 KB
実行使用メモリ 6,068 KB
最終ジャッジ日時 2023-09-08 12:02:50
合計ジャッジ時間 1,120 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,044 KB
testcase_01 AC 12 ms
6,056 KB
testcase_02 AC 13 ms
5,872 KB
testcase_03 AC 12 ms
6,052 KB
testcase_04 AC 11 ms
6,036 KB
testcase_05 AC 11 ms
6,024 KB
testcase_06 AC 12 ms
5,876 KB
testcase_07 AC 12 ms
5,864 KB
testcase_08 AC 12 ms
5,896 KB
testcase_09 AC 12 ms
5,880 KB
testcase_10 AC 12 ms
5,936 KB
testcase_11 AC 12 ms
6,068 KB
testcase_12 AC 12 ms
6,052 KB
testcase_13 AC 11 ms
5,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

lst=[1]
def calc(x,a):
  d=bin(a)[2:]
  ans=1
  for i in xrange(len(d)):
    if d[i]=="1":
      ans*=lst[len(d)-i]
  return ans

x,N=map(int,raw_input().split())
lst.append(x)
for i in xrange(2,33):
  lst.append(lst[i-1]**2%1000003)
a=map(int,raw_input().split())
ans=0
for i in xrange(N):
  ans+=calc(x,a[i])
  ans=ans%1000003
print ans
0