結果
問題 | No.2260 Adic Sum |
ユーザー |
|
提出日時 | 2023-04-07 22:07:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 350 ms / 2,000 ms |
コード長 | 1,566 bytes |
コンパイル時間 | 2,231 ms |
コンパイル使用メモリ | 201,280 KB |
最終ジャッジ日時 | 2025-02-12 01:28:53 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> // clang-format off using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; const ll INF=4e18; void print0(){}; template<typename H,typename... T> void print0(H h,T... t){cout<<h;print0(t...);} void print(){print0("\n");}; template<typename H,typename... T>void print(H h,T... t){print0(h);if(sizeof...(T)>0)print0(" ");print(t...);} void perr0(){}; template<typename H,typename... T> void perr0(H h,T... t){cerr<<h;perr0(t...);} void perr(){perr0("\n");}; template<typename H,typename... T>void perr(H h,T... t){perr0(h);if(sizeof...(T)>0)perr0(" ");perr(t...);} void ioinit() { cout<<fixed<<setprecision(15); cerr<<fixed<<setprecision(6); ios_base::sync_with_stdio(0); cin.tie(0); } #define debug1(a) { cerr<<#a<<":"<<a<<endl; } #define debug2(a,b) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<endl; } #define debug3(a,b,c) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<endl; } #define debug4(a,b,c,d) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<" "<<#d<<":"<<d<<endl; } // clang-format on int main() { ioinit(); ll N, P; cin >> N >> P; vector<ll> A(N); for (ll i = 0; i < N; i++) { cin >> A[i]; } const ll MX = 1000000000; ll ans = 0; ll pp = P; while (pp <= MX) { unordered_map<ll, ll> mods; for (ll i = 0; i < N; i++) { mods[A[i] % pp]++; } for (auto mp : mods) { ll c = mp.second; ans += c * (c - 1) / 2; } pp *= P; } print(ans); return 0; }