結果
問題 |
No.16 累乗の加算
|
ユーザー |
![]() |
提出日時 | 2019-07-23 21:29:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 431 bytes |
コンパイル時間 | 1,493 ms |
コンパイル使用メモリ | 168,704 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-26 09:17:35 |
合計ジャッジ時間 | 2,108 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 WA * 12 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:22:17: warning: 's' may be used uninitialized [-Wmaybe-uninitialized] 22 | cout << s % 1000003 << endl; | ^~~~~~~ main.cpp:15:15: note: 's' was declared here 15 | int x, n, s; | ^
ソースコード
#include <bits/stdc++.h> using namespace std; int power(int x, int a) { if (a == 0) return 1; if (a % 2 == 0) { return power(x * x % 1000003, a / 2); } else { return power(x * x % 1000003, a / 2) * x % 1000003; } } int main() { int x, n, s; cin >> x >> n; for (int i = 0; i < n; i++) { int a; cin >> a; s += power(x, a); } cout << s % 1000003 << endl; }