結果

問題 No.2260 Adic Sum
ユーザー 👑 nu50218nu50218
提出日時 2024-04-21 13:16:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 817 ms / 2,000 ms
コード長 826 bytes
コンパイル時間 2,351 ms
コンパイル使用メモリ 202,696 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2024-04-21 13:16:40
合計ジャッジ時間 8,454 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 22 ms
6,016 KB
testcase_15 AC 32 ms
7,168 KB
testcase_16 AC 18 ms
5,632 KB
testcase_17 AC 34 ms
7,424 KB
testcase_18 AC 484 ms
9,600 KB
testcase_19 AC 504 ms
10,240 KB
testcase_20 AC 324 ms
10,112 KB
testcase_21 AC 374 ms
10,112 KB
testcase_22 AC 285 ms
9,856 KB
testcase_23 AC 183 ms
10,112 KB
testcase_24 AC 479 ms
10,240 KB
testcase_25 AC 55 ms
9,600 KB
testcase_26 AC 84 ms
9,600 KB
testcase_27 AC 56 ms
9,856 KB
testcase_28 AC 53 ms
9,600 KB
testcase_29 AC 54 ms
9,856 KB
testcase_30 AC 60 ms
7,552 KB
testcase_31 AC 168 ms
8,192 KB
testcase_32 AC 162 ms
8,064 KB
testcase_33 AC 64 ms
10,240 KB
testcase_34 AC 117 ms
10,368 KB
testcase_35 AC 817 ms
10,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef LOCAL
#include <local.hpp>
#else
#include <bits/stdc++.h>
#define debug(...) ((void)0)
#define postprocess(...) ((void)0)
#endif

using namespace std;
using ll = long long;
using ld = long double;

void solve([[maybe_unused]] int test) {
    ll N, P;
    cin >> N >> P;

    vector<ll> A(N);
    for (auto&& x : A) {
        cin >> x;
    }

    ll ans = 0;

    ll MOD = P;

    while (MOD <= *max_element(A.begin(), A.end())) {
        map<ll, int> m;
        for (int i = 0; i < N; i++) {
            ll rem = A[i] % MOD;
            ans += m[rem];
            m[rem]++;
        }

        MOD *= P;
    }

    cout << ans << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) {
        solve(i);
    }

    postprocess();
}
0