結果
問題 |
No.16 累乗の加算
|
ユーザー |
![]() |
提出日時 | 2018-12-07 01:58:38 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 455 bytes |
コンパイル時間 | 1,207 ms |
コンパイル使用メモリ | 158,620 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-14 03:09:01 |
合計ジャッジ時間 | 3,948 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | RE * 14 |
コンパイルメッセージ
main.cpp: In function ‘int powModM(long int, long int)’: main.cpp:7:39: warning: control reaches end of non-void function [-Wreturn-type] 7 | else (powModM(x,a-1) * (x % M)) % M; | ^
ソースコード
#include <bits/stdc++.h> int M = 1000003; using namespace std; int powModM(long int x,long int a){ if(a == 0) return 1; else if(a%2 == 0) return (powModM(x,a/2) * powModM(x,a/2)) % M; else (powModM(x,a-1) * (x % M)) % M; } int main(){ long long int sum = 0; long long int ans; int x,N; cin >> x >> N; int a; for(int i=0;i<N;i++){ cin >> a; sum += powModM(x,a); } ans = sum % M; return ans; }