<pre name="code" class="cpp">#include <cstdio>
#include <map>
#include <iostream>
using namespace std;
#define LL long long
map<LL, LL> s1, s2;
// t2 表示以某值为等比数列中项的次数.
// t1 表示在第i个数之前每个值出现的次数
// 这样只要统计每一个值能构成的等比数列数目即可
int n, k;
int main()
{
cin>>n>>k;
s1.clear();
s2.clear();
long long ans = 0;
for(int i = 1; i <= n; i++)
{
int t;
scanf("%d", &t);
if(t % k == 0)
{
ans += s2[t / k];
s2[t] += s1[t / k];
}
s1[t]++;
}
printf("%I64d\n", ans);
return 0;
}
cf 567 c
最新推荐文章于 2019-11-05 22:57:14 发布