結果
問題 | No.16 累乗の加算 |
ユーザー |
![]() |
提出日時 | 2015-07-25 18:21:33 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 634 bytes |
コンパイル時間 | 542 ms |
コンパイル使用メモリ | 58,884 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 04:57:35 |
合計ジャッジ時間 | 1,219 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
#include <iostream> #include <string> #include <vector> using namespace std; typedef long long LL; const LL MOD = 1000003; LL modpow_internal(LL M, LL N){ if(N <= 0) return 1; LL ans = modpow_internal(M, N/2); ans = ans*ans%MOD; if(N%2 == 1) ans = ans*M%MOD; return ans; } LL modpow(LL M, LL N){ if(N == 0) return 1; if(M == 0) return 0; return modpow_internal(M, N); } int main(){ LL x = 0, N = 0; cin >> x >> N; LL ans = 0; for(int i = 0; i < N; i++){ LL a; cin >> a; ans += modpow(x, a); ans %= MOD; } cout << ans << endl; return 0; }