結果
問題 | No.2260 Adic Sum |
ユーザー |
|
提出日時 | 2023-04-26 17:47:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,065 ms / 2,000 ms |
コード長 | 632 bytes |
コンパイル時間 | 947 ms |
コンパイル使用メモリ | 89,224 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-11-16 00:47:07 |
合計ジャッジ時間 | 8,956 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#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; }