結果

問題 No.2260 Adic Sum
ユーザー 👑 nu50218nu50218
提出日時 2023-04-07 21:34:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 814 ms / 2,000 ms
コード長 919 bytes
コンパイル時間 2,946 ms
コンパイル使用メモリ 228,020 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2024-04-27 04:35:31
合計ジャッジ時間 8,612 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 3 ms
6,940 KB
testcase_13 AC 3 ms
6,940 KB
testcase_14 AC 23 ms
6,940 KB
testcase_15 AC 33 ms
7,168 KB
testcase_16 AC 20 ms
6,944 KB
testcase_17 AC 37 ms
7,424 KB
testcase_18 AC 505 ms
9,728 KB
testcase_19 AC 552 ms
10,240 KB
testcase_20 AC 351 ms
9,984 KB
testcase_21 AC 342 ms
10,112 KB
testcase_22 AC 283 ms
9,856 KB
testcase_23 AC 194 ms
10,240 KB
testcase_24 AC 488 ms
10,240 KB
testcase_25 AC 55 ms
9,728 KB
testcase_26 AC 53 ms
9,472 KB
testcase_27 AC 56 ms
9,984 KB
testcase_28 AC 53 ms
9,728 KB
testcase_29 AC 55 ms
9,856 KB
testcase_30 AC 61 ms
7,552 KB
testcase_31 AC 164 ms
8,064 KB
testcase_32 AC 163 ms
8,064 KB
testcase_33 AC 61 ms
10,240 KB
testcase_34 AC 112 ms
10,240 KB
testcase_35 AC 814 ms
10,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef LOCAL
#include <local.hpp>
#else
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2")
#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