結果
問題 | No.2260 Adic Sum |
ユーザー |
![]() |
提出日時 | 2023-04-08 07:07:19 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 869 ms / 2,000 ms |
コード長 | 585 bytes |
コンパイル時間 | 2,903 ms |
コンパイル使用メモリ | 255,272 KB |
実行使用メモリ | 10,240 KB |
最終ジャッジ日時 | 2024-10-06 07:25:38 |
合計ジャッジ時間 | 9,602 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define int long longint32_t main(){int n, p;cin >> n >> p;vector<int> a(n);for(auto& x : a) cin >> x;vector<int> tank = {p};for(int i = 0; i < 60; i++){if(tank.back() > 1e9) break;tank.push_back(tank.back() * p);}int ans = 0;for(int v : tank){map<int, int> mp;for(int i = 0; i < n; i++){mp[a[i] % v]++;}for(auto[key, val] : mp){ans += val * (val - 1) / 2;}}cout << ans << endl;return 0;}