結果

問題 No.16 累乗の加算
ユーザー KuphonyKuphony
提出日時 2016-03-17 21:40:20
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 828 bytes
コンパイル時間 583 ms
コンパイル使用メモリ 65,880 KB
実行使用メモリ 9,748 KB
最終ジャッジ日時 2024-04-08 16:46:36
合計ジャッジ時間 6,952 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <list>
using namespace std;

int main(int argc, const char * argv[]) {
    long long x;
    cin >> x;
    long long N;
    cin >> N;
    long long n;
    long long div = 1000003;
    long long result = 0;
    long long tmp = x;
    long long count = 0;
    vector<long long>a;
    for (int i = 0; i < N; i++) {
        cin >> n;
        if (n != 0) {
            while(count < n - 1){
                if(tmp > div){
                    tmp %= div;
                }
                tmp *= x;
                count++;
            }
            result += tmp;
            tmp = x;
            count = 0;
        }
        else{
            result += 1;
        }
    }
    cout << result%div;
    cout << "\n";
}
0