結果

問題 No.2260 Adic Sum
ユーザー karinohitokarinohito
提出日時 2023-03-15 00:32:32
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 935 ms / 2,000 ms
コード長 372 bytes
コンパイル時間 2,166 ms
コンパイル使用メモリ 209,616 KB
実行使用メモリ 9,984 KB
最終ジャッジ日時 2024-10-06 06:51:26
合計ジャッジ時間 8,463 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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){
        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