結果
| 問題 |
No.16 累乗の加算
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-05 22:15:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 439 bytes |
| コンパイル時間 | 487 ms |
| コンパイル使用メモリ | 65,528 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-23 14:24:50 |
| 合計ジャッジ時間 | 1,083 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
#include <iostream>
using namespace std;
long power(long a, long b, long mod) {
if (b == 0) return 1;
long res = power(a, b / 2, mod);
if (b % 2) res = res * res % mod * a % mod;
else res = res * res % mod;
return res;
}
int main() {
long x;
cin >> x;
int N;
cin >> N;
long ans = 0;
for (int i = 0; i < N; ++i) {
long a;
cin >> a;
ans += power(x, a, 1000003);
ans %= 1000003;
}
cout << ans;
}