You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
533 B
C++
23 lines
533 B
C++
#define _CRT_SECURE_NO_WARNINGS
|
|
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
|
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
int main()
|
|
{
|
|
ios::sync_with_stdio(false);
|
|
int64_t n, k;
|
|
cin >> n >> k;
|
|
vector<int64_t> v(n);
|
|
unordered_map<int64_t, int64_t> m1, m2;
|
|
for (auto &x : v) cin >> x, m2[x]++;
|
|
int64_t ans = 0;
|
|
for (auto &x : v)
|
|
{
|
|
--m2[x];
|
|
if (x % k == 0)
|
|
ans += m1[x / k] * m2[x * k];
|
|
++m1[x];
|
|
}
|
|
cout << ans;
|
|
return 0;
|
|
} |