結果
| 問題 | No.16 累乗の加算 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-18 21:09:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 798 bytes |
| コンパイル時間 | 1,713 ms |
| コンパイル使用メモリ | 168,320 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-14 02:29:41 |
| 合計ジャッジ時間 | 2,420 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)
typedef long long ll;
typedef long double ld;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e6 + 3;
ll modpower(ll a, ll n, ll mod) {
ll res = 1;
while (n > 0) {
if (n & 1) res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(0);
int x, n;
cin >> x >> n;
vector<int> a(n);
rep (i, n) cin >> a[i];
ll res = 0;
rep (i, n) {
res += modpower(x, a[i], MOD);
res %= MOD;
}
cout << res << endl;
return 0;
}