結果

問題 No.2260 Adic Sum
ユーザー t98slidert98slider
提出日時 2023-04-07 21:29:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,998 ms / 2,000 ms
コード長 595 bytes
コンパイル時間 1,900 ms
コンパイル使用メモリ 171,576 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2024-04-15 23:43:10
合計ジャッジ時間 14,122 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 4 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 4 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 5 ms
6,940 KB
testcase_13 AC 3 ms
6,940 KB
testcase_14 AC 21 ms
6,944 KB
testcase_15 AC 32 ms
7,040 KB
testcase_16 AC 19 ms
6,940 KB
testcase_17 AC 63 ms
7,680 KB
testcase_18 AC 1,103 ms
9,728 KB
testcase_19 AC 1,236 ms
10,240 KB
testcase_20 AC 843 ms
9,856 KB
testcase_21 AC 872 ms
10,112 KB
testcase_22 AC 654 ms
9,856 KB
testcase_23 AC 367 ms
10,112 KB
testcase_24 AC 1,278 ms
10,240 KB
testcase_25 AC 58 ms
9,600 KB
testcase_26 AC 59 ms
9,472 KB
testcase_27 AC 65 ms
9,856 KB
testcase_28 AC 62 ms
9,600 KB
testcase_29 AC 60 ms
9,728 KB
testcase_30 AC 114 ms
10,240 KB
testcase_31 AC 488 ms
10,240 KB
testcase_32 AC 486 ms
10,240 KB
testcase_33 AC 74 ms
10,240 KB
testcase_34 AC 225 ms
10,240 KB
testcase_35 AC 1,998 ms
10,240 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template<typename T>
T MUL(T a, T b){
    T res;
    return __builtin_mul_overflow(a, b, &res)? std::numeric_limits<T>::max() : res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, P;
    cin >> N >> P;
    vector<ll> a(N);
    for(auto &&v : a) cin >> v;
    ll d = 1, ans = 0;
    while(MUL(d, P) <= 1'000'000'000'000'00){
        d *= P;
        map<ll, ll> mp;
        for(int i = 0; i < N; i++){
            ll c = a[i] % d;
            ans += mp[c]++;
        }
    }
    cout << ans << '\n';
}
0