結果
問題 | No.2260 Adic Sum |
ユーザー |
|
提出日時 | 2023-04-08 12:43:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 779 ms / 2,000 ms |
コード長 | 594 bytes |
コンパイル時間 | 1,990 ms |
コンパイル使用メモリ | 205,896 KB |
最終ジャッジ日時 | 2025-02-12 03:51:51 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> typedef long long ll; using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); ll n, p; cin >> n >> p; vector<ll> a(n); for(int i = 0; i < n; i++) cin >> a[i]; vector<ll> f = {1}; while(f.back()*p <= 1e9){ f.push_back(f.back()*p); } int m = f.size(); vector<map<ll,ll>> mp(30); for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ mp[i][a[j]%f[i]]++; } } ll ans = 0; map<ll,ll> mq; for(int i = 1; i < m; i++){ for(auto [k, v]: mp[i]){ ans += v*(v-1)/2; } } cout << ans << endl; }