結果

問題 No.16 累乗の加算
ユーザー tetsuzuki1115tetsuzuki1115
提出日時 2018-01-08 00:05:36
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 823 bytes
コンパイル時間 563 ms
コンパイル使用メモリ 75,392 KB
実行使用メモリ 7,500 KB
最終ジャッジ日時 2023-09-08 12:12:08
合計ジャッジ時間 1,844 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
7,232 KB
testcase_01 AC 20 ms
7,276 KB
testcase_02 AC 20 ms
7,228 KB
testcase_03 AC 20 ms
7,220 KB
testcase_04 AC 20 ms
7,224 KB
testcase_05 AC 20 ms
7,264 KB
testcase_06 AC 21 ms
7,256 KB
testcase_07 AC 20 ms
7,236 KB
testcase_08 AC 20 ms
7,332 KB
testcase_09 AC 20 ms
7,500 KB
testcase_10 WA -
testcase_11 AC 20 ms
7,272 KB
testcase_12 AC 20 ms
7,316 KB
testcase_13 AC 21 ms
7,256 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;

int M[1000003];

int main() {        
    
    long long 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[ (A[i]/MOD) + (A[i]%MOD) ] : M[A[i]] );
        ans %= MOD;
    }
    
    cout << ans << endl;
    
    return 0;
}

0