結果
問題 |
No.2260 Adic Sum
|
ユーザー |
![]() |
提出日時 | 2023-04-22 03:47:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 827 ms / 2,000 ms |
コード長 | 692 bytes |
コンパイル時間 | 3,769 ms |
コンパイル使用メモリ | 113,084 KB |
最終ジャッジ日時 | 2025-02-12 12:55:30 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#include <iostream> #include <vector> #include <cmath> #include <map> #include <set> #include <iomanip> #include <queue> #include <algorithm> #include <numeric> #include <deque> #include <complex> #include <cassert> using namespace std; using ll = long long; int main(){ ll N, P, ans=0, log=0, B; cin >> N >> P; B = 1; while(B <= 1e9/P){ B *= P; log++; } vector<ll> A(N); for (int i=0; i<N; i++) cin >> A[i]; B = P; for (int i=0; i<log; i++){ map<ll, ll> mp; for (ll j=0; j<N; j++){ ans += mp[A[j] % B]; mp[A[j] % B]++; } B *= P; } cout << ans << endl; return 0; }