結果

問題 No.2260 Adic Sum
ユーザー RedstoneGamer22RedstoneGamer22
提出日時 2023-04-10 21:50:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 436 ms / 2,000 ms
コード長 435 bytes
コンパイル時間 2,264 ms
コンパイル使用メモリ 200,496 KB
実行使用メモリ 9,152 KB
最終ジャッジ日時 2024-04-16 00:37:53
合計ジャッジ時間 6,608 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 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 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 26 ms
5,376 KB
testcase_15 AC 40 ms
5,988 KB
testcase_16 AC 23 ms
5,376 KB
testcase_17 AC 42 ms
6,016 KB
testcase_18 AC 291 ms
9,016 KB
testcase_19 AC 320 ms
9,040 KB
testcase_20 AC 209 ms
8,896 KB
testcase_21 AC 212 ms
8,904 KB
testcase_22 AC 172 ms
9,152 KB
testcase_23 AC 111 ms
8,324 KB
testcase_24 AC 254 ms
9,040 KB
testcase_25 AC 70 ms
8,312 KB
testcase_26 AC 68 ms
8,428 KB
testcase_27 AC 70 ms
8,452 KB
testcase_28 AC 69 ms
8,436 KB
testcase_29 AC 68 ms
8,308 KB
testcase_30 AC 57 ms
6,160 KB
testcase_31 AC 114 ms
6,356 KB
testcase_32 AC 114 ms
6,608 KB
testcase_33 AC 57 ms
8,460 KB
testcase_34 AC 102 ms
8,324 KB
testcase_35 AC 436 ms
8,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, p; cin >> n >> p;
    vector<int> a(n); for(auto &e : a) cin >> e;

    int64_t ans = 0;
    for(int64_t pow = p; pow <= 1e9 + 1; pow *= p) {
        unordered_map<int, int> hm;
        for(auto e : a) hm[e % pow] += 1;

        for(auto e : hm) {
            ans += 1LL * e.second * (e.second - 1) / 2;
        }
    }

    cout << ans << endl;

    return 0;
}
0