forked from amankayat/HackerRank-Solution-Algorithm-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdivisiblesumpairs.cpp
More file actions
63 lines (49 loc) · 1.02 KB
/
divisiblesumpairs.cpp
File metadata and controls
63 lines (49 loc) · 1.02 KB
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
<<<<<<< HEAD
#include<iostream>
#include<stdio.h>
using namespace std;
int div_sumpair(int n,int a[],int k){
int count=0;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(i<j){
if((a[i]+a[j])%k==0)
count++;
}
}
}
return count;
}
int main(){
int n,k,a[100];
cin>>n>>k;
for(int i=0;i<n;i++)
cin>>a[i];
int result = div_sumpair(n,a,k);
cout<<result;
}
=======
#include<iostream>
#include<stdio.h>
using namespace std;
int div_sumpair(int n,int a[],int k){
int count=0;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(i<j){
if((a[i]+a[j])%k==0)
count++;
}
}
}
return count;
}
int main(){
int n,k,a[100];
cin>>n>>k;
for(int i=0;i<n;i++)
cin>>a[i];
int result = div_sumpair(n,a,k);
cout<<result;
}
>>>>>>> 58571b3271e22517b4a2df95d9928c42429c3fe6