結果
| 問題 | No.16 累乗の加算 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-01-16 23:52:22 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 555 bytes |
| 記録 | |
| コンパイル時間 | 1,638 ms |
| コンパイル使用メモリ | 184,344 KB |
| 実行使用メモリ | 7,852 KB |
| 最終ジャッジ日時 | 2026-01-16 23:52:25 |
| 合計ジャッジ時間 | 2,633 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=1'000'003;
ll add(ll a,ll b){return (a+b)%MOD;}
ll mdpw(ll a,ll b){
ll ret=1;
a%=MOD;
while(b){
if(b&1)ret=(ret*a)%MOD;
a=(a*a)%MOD;b>>=1;
}
return ret;
}
void solve(){
ll x;int n;cin>>x>>n;
int ans=0;
for(int i=0,e;i<n;++i){
cin>>e;
ans=add(ans,mdpw(x,e));
}
cout<<ans<<endl;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(nullptr);
int T=1; //cin>>T;
while(T--)solve();
return 0;
}