-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathD_Divisible_Pairs.cpp
More file actions
47 lines (47 loc) · 854 Bytes
/
Copy pathD_Divisible_Pairs.cpp
File metadata and controls
47 lines (47 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<long, long> pi;
typedef unordered_map<ll, ll> mpp;
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define fr(i, a, b) for (int i = a; i < b; i++)
#define get(a) \
for (auto &i : a) \
cin >> i
void wushangclan()
{
ll n, x, y;
cin >> n >> x >> y;
vl v(n);
get(v);
map<pi, int> mp;
ll ans = 0;
fr(i, 0, n)
{
ans += mp[{x - (v[i] % x), v[i] % y}];
if ((v[i] % x )!= 0)
{
mp[{v[i] % x, v[i] % y}]++;
}
else
{
mp[{x, v[i] % y}]++;
}
}
cout << ans << endl;
}
int main()
{
int t;
cin >> t;
while (t--)
{
wushangclan();
}
return 0;
}