結果

問題 No.16 累乗の加算
ユーザー tetsuzuki1115tetsuzuki1115
提出日時 2018-01-07 23:38:45
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 808 bytes
コンパイル時間 2,083 ms
コンパイル使用メモリ 74,968 KB
実行使用メモリ 11,456 KB
最終ジャッジ日時 2023-08-24 23:46:33
合計ジャッジ時間 1,933 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
11,156 KB
testcase_01 AC 21 ms
11,192 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 WA -
testcase_12 WA -
testcase_13 AC 21 ms
11,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000003;

long long M[1000003];

int main() {
        
    
    int x,N;
    cin >> x >> N;
    
    vector<long long> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    
    M[0] = 1;
    long long a = 1;
    for ( int i = 1; i < 1000003; i++ ) {
        a *= x;
        a %= MOD;
        M[i] = a;
    }
    
    long long ans = 0;
    for ( int i = 0; i < N; i++ ) {
        ans += ( A[i] >= MOD ) ? M[ 1 + A[i]%MOD ] : M[A[i]];
        ans %= MOD;
    }
    
    cout << ans << endl;
    
    return 0;
}
0