結果
| 問題 |
No.16 累乗の加算
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-30 20:14:27 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 604 bytes |
| コンパイル時間 | 1,977 ms |
| コンパイル使用メモリ | 192,444 KB |
| 最終ジャッジ日時 | 2025-02-25 01:53:08 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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';
}