結果
| 問題 | No.16 累乗の加算 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-30 20:14:27 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 0 ms / 5,000 ms |
| コード長 | 604 bytes |
| 記録 | |
| コンパイル時間 | 1,013 ms |
| コンパイル使用メモリ | 211,416 KB |
| 実行使用メモリ | 9,224 KB |
| 最終ジャッジ日時 | 2026-07-06 03:05:10 |
| 合計ジャッジ時間 | 2,255 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (int i = (int)s; i < (int)e; ++i)
#define all(a) (a).begin(), (a).end()
ll modpow(ll a, ll n, ll m) {
ll res = 1;
while (n > 0) {
if (n & 1) res = res * a % m;
a = a * a % m;
n >>= 1;
}
return res;
}
const ll mod = 1000003;
int main() {
cin.tie(nullptr);
ll x, N;
cin >> x >> N;
ll ans = 0;
rep(i, 0, N) {
ll a;
cin >> a;
ans += modpow(x, a, mod);
ans %= mod;
}
cout << ans << '\n';
}