結果

問題 No.2260 Adic Sum
ユーザー ruthenruthen
提出日時 2023-04-14 23:50:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,000 ms / 2,000 ms
コード長 773 bytes
コンパイル時間 2,374 ms
コンパイル使用メモリ 204,416 KB
実行使用メモリ 63,856 KB
最終ジャッジ日時 2024-04-18 21:25:18
合計ジャッジ時間 8,574 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 14 ms
5,376 KB
testcase_15 AC 18 ms
6,100 KB
testcase_16 AC 13 ms
5,376 KB
testcase_17 AC 23 ms
6,152 KB
testcase_18 AC 506 ms
38,900 KB
testcase_19 AC 502 ms
41,048 KB
testcase_20 AC 327 ms
27,808 KB
testcase_21 AC 327 ms
29,232 KB
testcase_22 AC 259 ms
24,748 KB
testcase_23 AC 119 ms
15,596 KB
testcase_24 AC 513 ms
37,784 KB
testcase_25 AC 38 ms
8,692 KB
testcase_26 AC 36 ms
8,680 KB
testcase_27 AC 37 ms
8,600 KB
testcase_28 AC 34 ms
8,564 KB
testcase_29 AC 34 ms
8,700 KB
testcase_30 AC 35 ms
6,736 KB
testcase_31 AC 173 ms
9,416 KB
testcase_32 AC 158 ms
9,420 KB
testcase_33 AC 31 ms
9,016 KB
testcase_34 AC 106 ms
23,392 KB
testcase_35 AC 1,000 ms
63,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#ifdef _RUTHEN
#include <debug.hpp>
#else
#define show(...) true
#endif

using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
template <class T> using V = vector<T>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long N, P;
    cin >> N >> P;
    V<long long> A(N);
    rep(i, N) cin >> A[i];
    V<long long> B;
    long long c = 1;
    while (c <= 1000000000LL / P) {
        B.push_back(c * P);
        c *= P;
    }
    show(B);
    int K = B.size();
    long long ans = 0;
    V<unordered_map<long long, int>> r(K);
    rep(i, N) {
        rep(j, K) {
            ans += r[j][A[i] % B[j]];
            r[j][A[i] % B[j]]++;
        }
    }
    cout << ans << '\n';
    return 0;
}
0