結果
| 問題 | No.16 累乗の加算 |
| コンテスト | |
| ユーザー |
hanorver
|
| 提出日時 | 2016-05-03 16:19:16 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| + 298µs | |
| コード長 | 469 bytes |
| 記録 | |
| コンパイル時間 | 301 ms |
| コンパイル使用メモリ | 73,472 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-30 08:14:33 |
| 合計ジャッジ時間 | 1,376 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
#include<iostream>
#define W 1000003
long long pow(long long x, int num) {
if (num == 0) return 1;
if (num == 1) return x;
if (num % 2 == 0) {
long long n = pow(x, num / 2);
return (n * n) % W;
} else {
return pow(x, num - 1) * x % W;
}
}
int main() {
long long x, n;
std::cin >> x >> n;
long long ans = 0;
for (int i = 0; i < n; i++) {
int num;
std::cin >> num;
ans += pow(x, num);
ans %= W;
}
std::cout << ans << std::endl;
return 0;
}
hanorver