結果
| 問題 | No.16 累乗の加算 |
| コンテスト | |
| ユーザー |
ManjushriMitra
|
| 提出日時 | 2024-07-27 11:15:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 589 bytes |
| コンパイル時間 | 1,808 ms |
| コンパイル使用メモリ | 168,336 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-27 11:15:31 |
| 合計ジャッジ時間 | 3,031 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,m,n) for(int i=m; i<n; ++i)
#define repl(i,m,n) for(ll i=m; i<n; ++i)
ll powmod(ll x, ll n, ll mod){
ll res = 1LL;
while(n){
if(n & 1LL) res = res * x % mod;
x = x * x % mod;
n >>= 1LL;
}
return res;
}
int main(){
ll x; int N;
cin >> x >> N;
vector<ll> a(N);
for(ll &aa : a) cin >> aa;
const ll mod = 1000003LL;
ll ans = 0LL;
rep(i, 0, N){
ans = (ans + powmod(x, a[i], mod)) % mod;
}
cout << ans << endl;
return 0;
}
ManjushriMitra