結果
| 問題 |
No.16 累乗の加算
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-08-23 23:52:55 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 454 bytes |
| コンパイル時間 | 2,635 ms |
| コンパイル使用メモリ | 275,780 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-08-23 23:52:59 |
| 合計ジャッジ時間 | 3,381 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000003;
ll xp[30];
int main(void) {
int N;
cin >> xp[0] >> N;
for(int i = 1; i < 30; ++i) xp[i] = (xp[i - 1] * xp[i - 1]) % mod;
ll ans = 0;
for(int i = 0; i < N; ++i) {
int A;
cin >> A;
ll r = 1;
for(auto it = xp; A != 0; it ++, A >>= 1) if(A & 1) r = (r * (*it)) % mod;
ans += r;
if(ans >= mod) ans -= mod;
}
cout << ans << endl;
return 0;
}