結果

問題 No.16 累乗の加算
ユーザー カルロスカルロス
提出日時 2015-08-31 15:25:34
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 456 bytes
コンパイル時間 697 ms
コンパイル使用メモリ 24,172 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-25 21:10:20
合計ジャッジ時間 1,166 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>

long long mpow(int mx, long long ma){
    if(ma==1){return mx;}
    if(ma==0){return  1;}
    if(ma%2==1){
        return mx * mpow(mx, ma-1) % 1000003;
    }else{
        return mpow(mx, ma/2) * mpow(mx, ma/2) % 1000003;
    }
}

int main(void){
    int i, x, N;
    scanf("%d %d", &x, &N);
    long long t = 0, a;
    for(i=0;i<N;i++){
        scanf("%lld", &a);
        t += mpow(x, a);
    }
    printf("%lld\n", t);
    return 0;
}
0