結果

問題 No.2260 Adic Sum
ユーザー akinyanakinyan
提出日時 2023-04-08 01:49:17
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 895 ms / 2,000 ms
コード長 1,030 bytes
コンパイル時間 3,918 ms
コンパイル使用メモリ 281,436 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2024-04-15 23:59:06
合計ジャッジ時間 9,641 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 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 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 34 ms
6,016 KB
testcase_15 AC 48 ms
7,168 KB
testcase_16 AC 29 ms
5,760 KB
testcase_17 AC 53 ms
7,424 KB
testcase_18 AC 487 ms
9,856 KB
testcase_19 AC 543 ms
10,240 KB
testcase_20 AC 356 ms
9,984 KB
testcase_21 AC 390 ms
10,112 KB
testcase_22 AC 299 ms
9,856 KB
testcase_23 AC 207 ms
10,368 KB
testcase_24 AC 505 ms
10,240 KB
testcase_25 AC 83 ms
9,856 KB
testcase_26 AC 81 ms
9,728 KB
testcase_27 AC 89 ms
10,112 KB
testcase_28 AC 85 ms
9,728 KB
testcase_29 AC 86 ms
9,728 KB
testcase_30 AC 79 ms
7,552 KB
testcase_31 AC 144 ms
8,192 KB
testcase_32 AC 144 ms
8,192 KB
testcase_33 AC 79 ms
10,240 KB
testcase_34 AC 116 ms
10,240 KB
testcase_35 AC 895 ms
10,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ch = char;
using ll = long long;
using ld = long double;
using db = double;
using st = string;
using vdb = vector<db>;
using vvdb = vector<vdb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<ld>;
using vvd = vector<vd>;
using vs = vector<st>;
using vvs = vector<vs>;
using vc = vector<ch>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
const ll mod = 998244353;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000LL;
using pall = pair<ll,ll>;
using vp = vector<pall>;

int main(){
    ll N,P;
    cin>>N>>P;
    vl A(N);
    ll MAX=0;
    for(int i=0; i<N; i++){
        cin>>A[i];
        MAX = max(MAX,A[i]);
    }
    ll ans = 0;
    for(ll i=P; i<=MAX; i*=P){
        map<ll,ll> X;
        for(int j=0; j<N; j++){
            X[A[j]%i]++;
        }
        for(auto mp:X){
            ans += mp.second * (mp.second - 1) /2;
        }
    }
    cout << ans << endl;
}
0