結果

問題 No.16 累乗の加算
ユーザー eve__fuyuki
提出日時 2018-03-13 17:58:04
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 266 ms / 5,000 ms
コード長 452 bytes
コンパイル時間 447 ms
コンパイル使用メモリ 54,796 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-26 05:27:04
合計ジャッジ時間 2,711 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
int main(){
    int x,N;
    int a[100];
    long long product,ans = 0;
    cin >> x >> N;
    for(int i=0;i<N;i++){
        cin >> a[i];
        a[i] %= 1000002;
    }
    for(int i=0;i<N;i++){
        product = 1;
        for(int j=0;j<a[i];j++){
            product *= x;
            product %= 1000003;
        }
        ans += product;
        ans %= 1000003;
    }
    cout << ans << endl;
    return 0;
}
0