結果
問題 |
No.16 累乗の加算
|
ユーザー |
|
提出日時 | 2019-03-05 22:13:03 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 420 bytes |
コンパイル時間 | 564 ms |
コンパイル使用メモリ | 65,420 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-23 14:24:49 |
合計ジャッジ時間 | 1,102 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 WA * 10 |
ソースコード
#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); } cout << ans; }