結果
問題 |
No.16 累乗の加算
|
ユーザー |
![]() |
提出日時 | 2018-04-24 21:20:28 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 34 ms / 5,000 ms |
コード長 | 576 bytes |
コンパイル時間 | 188 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-06-27 16:23:09 |
合計ジャッジ時間 | 1,156 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
def power(x,n): p=[] X=x if n==0: return 1 if n==1: return x while n!=1: if n%2==0: n=n/2 p.append(2) else: n=n-1 p.append(1) l=len(p) for i in range(l): if p[(l-1)-i]==2: X=X**2 else: X*=x if X>N: X=X%N return X%N num=list(map(int,input().split())) a=list(map(int,input().split())) N=1000003 total=0 for i in range(num[1]): total+=power(num[0],a[i]) print(total%N)