結果
| 問題 |
No.2260 Adic Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-04-07 21:34:41 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 763 bytes |
| コンパイル時間 | 7,761 ms |
| コンパイル使用メモリ | 267,052 KB |
| 最終ジャッジ日時 | 2025-02-12 00:40:41 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 TLE * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef _RUTHEN
#include <debug.hpp>
#else
#define show(...) true
#endif
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
template <class T> using V = vector<T>;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
long long N, P;
cin >> N >> P;
V<long long> A(N);
rep(i, N) cin >> A[i];
V<long long> B;
long long c = 1;
while (c <= 1000000000LL / P) {
B.push_back(c * P);
c *= P;
}
show(B);
int K = B.size();
long long ans = 0;
V<map<long long, int>> r(K);
rep(i, N) {
rep(j, K) {
ans += r[j][A[i] % B[j]];
r[j][A[i] % B[j]]++;
}
}
cout << ans << '\n';
return 0;
}