結果

問題 No.16 累乗の加算
ユーザー youjo_yamiotiyoujo_yamioti
提出日時 2018-12-07 02:02:28
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 499 bytes
コンパイル時間 1,344 ms
コンパイル使用メモリ 143,696 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-12 03:27:05
合計ジャッジ時間 2,248 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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){
        int t = powModM(x,a/2);
        return (t * t) % M;
    }else{
        return powModM(x,a-1) * (x % 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;
}
0