結果
問題 | No.16 累乗の加算 |
ユーザー |
|
提出日時 | 2020-05-28 04:41:01 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 477 bytes |
コンパイル時間 | 113 ms |
コンパイル使用メモリ | 29,824 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 04:00:59 |
合計ジャッジ時間 | 951 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
#include<stdio.h>#include<string.h>#include<stdlib.h>#include<stdbool.h>#include<time.h>#include<assert.h>#define mod 1000003long long power(long long a,long long b){long long x=1,y=a;while(b>0){if(b&1ll){x=(x*y)%mod;}y=(y*y)%mod;b>>=1;}return x%mod;}int main(void){long long x,n,a,i,r=0;scanf("%lld%lld",&x,&n);for(i=0;i<n;i++){scanf("%lld",&a);r+=power(x,a);r%=mod;}printf("%lld\n",r);return 0;}