結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i=0;i<(int)(n);i++)

int main(){
  int n,p;
  cin>>n>>p;
  vector<int> a(n);
  rep(i,n) cin>>a.at(i);
  ll np=p;
  ll ans=0;
  rep(i,32){
    map<int,ll> na;
    rep(i,n) na[a.at(i)%np]++;
    for(auto [nw,nm]:na){
      ans+=nm*(nm-1)/2;
    }
    np*=p;
    if(np>1e10) break;
  }
  cout<<ans<<endl;
}
0