結果
| 問題 |
No.2260 Adic Sum
|
| コンテスト | |
| ユーザー |
RedstoneGamer22
|
| 提出日時 | 2023-04-10 21:50:18 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 334 ms / 2,000 ms |
| コード長 | 435 bytes |
| コンパイル時間 | 1,798 ms |
| コンパイル使用メモリ | 199,364 KB |
| 最終ジャッジ日時 | 2025-02-12 04:51:26 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, p; cin >> n >> p;
vector<int> a(n); for(auto &e : a) cin >> e;
int64_t ans = 0;
for(int64_t pow = p; pow <= 1e9 + 1; pow *= p) {
unordered_map<int, int> hm;
for(auto e : a) hm[e % pow] += 1;
for(auto e : hm) {
ans += 1LL * e.second * (e.second - 1) / 2;
}
}
cout << ans << endl;
return 0;
}
RedstoneGamer22