結果

問題 No.2260 Adic Sum
ユーザー karinohito
提出日時 2023-03-15 00:43:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 412 ms / 2,000 ms
コード長 382 bytes
コンパイル時間 1,878 ms
コンパイル使用メモリ 199,248 KB
最終ジャッジ日時 2025-02-11 11:30:32
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    ll N,P;
    cin>>N>>P;
    vector<int> A(N);
    for(int i=0;i<N;i++)cin>>A[i];

    ll an=0;
    ll p=P;
    while(p<1e9+3){
        unordered_map<ll,ll> M;
        for(int i=0;i<N;i++){
            an+=M[A[i]%p];
            M[A[i]%p]++;
        }
        p*=P;
    }
    cout<<an<<endl;
    
}
0