結果

問題 No.16 累乗の加算
ユーザー drymousedrymouse
提出日時 2024-02-17 13:14:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 545 ms / 5,000 ms
コード長 575 bytes
コンパイル時間 810 ms
コンパイル使用メモリ 74,172 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-17 13:14:16
合計ジャッジ時間 7,044 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 538 ms
6,676 KB
testcase_03 AC 208 ms
6,676 KB
testcase_04 AC 264 ms
6,676 KB
testcase_05 AC 320 ms
6,676 KB
testcase_06 AC 375 ms
6,676 KB
testcase_07 AC 404 ms
6,676 KB
testcase_08 AC 497 ms
6,676 KB
testcase_09 AC 524 ms
6,676 KB
testcase_10 AC 538 ms
6,676 KB
testcase_11 AC 540 ms
6,676 KB
testcase_12 AC 545 ms
6,676 KB
testcase_13 AC 539 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

#define HOU 1000003

int main(void) {
    int x, N;
    cin >> x >> N;
    int a[N+1];
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(a, a+N, greater<int>());
    a[N] = -1;
    int index = 0;
    int result = 0;
    for (int i = a[0]; i >= 0; i--) {
        for (;i == a[index];) {
            result += 1;
            index++;
        }
        if (i == 0) {
            break;
        }
        result = (result * x) % HOU;
    }
    cout << (result % HOU) << endl;
    
    return 0;
}
0