結果
| 問題 | 
                            No.16 累乗の加算
                             | 
                    
| コンテスト | |
| ユーザー | 
                             youjo_yamioti
                         | 
                    
| 提出日時 | 2018-12-07 01:50:25 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                RE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 465 bytes | 
| コンパイル時間 | 1,417 ms | 
| コンパイル使用メモリ | 159,380 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-09-14 03:08:19 | 
| 合計ジャッジ時間 | 4,566 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | RE * 14 | 
コンパイルメッセージ
main.cpp: In function ‘int powModM(int, int)’:
main.cpp:7:37: 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(int x, 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;
    vector<int> a(N,0);
    for(int i=0;i<N;i++){
        cin >> a[i];
        sum += powModM(x,a[i]);
    }
    ans = sum % M;
    return ans;
}
            
            
            
        
            
youjo_yamioti