結果

問題 No.2260 Adic Sum
ユーザー ace_amuroace_amuro
提出日時 2023-04-26 17:47:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,104 ms / 2,000 ms
コード長 632 bytes
コンパイル時間 858 ms
コンパイル使用メモリ 89,156 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2024-04-27 19:42:41
合計ジャッジ時間 9,184 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 3 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 4 ms
6,944 KB
testcase_13 AC 4 ms
6,940 KB
testcase_14 AC 34 ms
6,940 KB
testcase_15 AC 51 ms
7,552 KB
testcase_16 AC 28 ms
6,940 KB
testcase_17 AC 56 ms
7,680 KB
testcase_18 AC 656 ms
9,984 KB
testcase_19 AC 720 ms
10,240 KB
testcase_20 AC 482 ms
10,240 KB
testcase_21 AC 503 ms
10,368 KB
testcase_22 AC 437 ms
10,112 KB
testcase_23 AC 237 ms
10,496 KB
testcase_24 AC 682 ms
10,496 KB
testcase_25 AC 95 ms
9,856 KB
testcase_26 AC 92 ms
9,856 KB
testcase_27 AC 104 ms
10,240 KB
testcase_28 AC 91 ms
9,984 KB
testcase_29 AC 96 ms
9,984 KB
testcase_30 AC 85 ms
7,808 KB
testcase_31 AC 172 ms
10,496 KB
testcase_32 AC 171 ms
10,496 KB
testcase_33 AC 77 ms
10,496 KB
testcase_34 AC 169 ms
10,368 KB
testcase_35 AC 1,104 ms
10,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<ctime>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
typedef long long LL;
const int MR=1e5+10;
int n;
LL p,a[MR];
int main(){
    cin>>n>>p;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    LL mod=1;
    LL ans=0;
    while(mod*p<2e9){
        mod*=p;
        map<LL,int> cnt;
        for(int i=1;i<=n;i++){
            cnt[a[i]%mod]++;
        }
        for(auto x:cnt){
            ans+=1ll*(x.second-1)*x.second/2;
        }
    }
    cout<<ans<<endl;
    return 0;
}
0