-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDivisible_Sum_Pairs.cpp
101 lines (93 loc) · 1.73 KB
/
Divisible_Sum_Pairs.cpp
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define pc putchar_unlocked
#define ll long long int
#define V_ll vector<ll>
#define V_int vector<int>
#define mp make_pair
#define pb push_back
#define M_ll multiset<ll>
#define M_int multiset<int>
#define IT iterator
#define pii pair<int,int>
#define pll pair<ll,ll>
#define FOR_Z(i,a) for(int i=0;i<a;++i)
#define FOR_A(i,a,b) for(int i=a;i<b;++i)
#define mod 1000000007
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
const int MOD = 1e9+7;
const int N = 1e6+10;
const ll inf = 1e18;
#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
ll q_sort (const void * a, const void * b)
{
return ( *(int*)a - *(int*)b );
}
//qsort(values, 5, sizeof(int), q_sort);
ll modpow(ll a, ll b)
{
ll r = 1;
while (b) {
if (b & 1) {
r = (r * a) % mod;
}
a = (a * a) % mod;
b >>= 1;
}
return r;
}
ll modpowinverse(ll a)
{
return modpow(a, mod - 2);
}
inline long long int sscan()
{
long long int n=0;
int ch=gc();
while( ch < '0' || ch > '9' )
ch=gc();
while( ch >= '0' && ch <= '9' )
{
n = (n<<3)+(n<<1) + ch-'0';
ch=gc();
}
return n;
}
void solve()
{
ll n, k, sum = 0;
n = sscan();
k = sscan();
ll arr[n];
FOR_Z(i,n)
{
arr[i] = sscan();
}
FOR_Z(i, n)
{
FOR_A(j, i+1, n)
{
if((arr[i] + arr[j]) % k == 0)
{
sum++;
}
}
}
printf("%lld\n",sum );
}
int main()
{
fast;
ll T = 1;
while(T--)
{
solve();
}
return 0;
}