728x90
반응형
문제 : 해커랭크 - Divisible Sum Pairs
난이도: Easy
언어 : C++
// Complete the divisibleSumPairs function below.
int divisibleSumPairs(int n, int k, vector<int> ar) {
int cnt = 0;
for(int i = 0; i< n-1 ; i++)
{
for(int j=i+1;j<n;j++)
{
if( (ar[i]+ar[j])%k == 0)
{
cnt++;
}
}
}
return cnt;
}
728x90
반응형
'개발 > 코딩' 카테고리의 다른 글
해커랭크(HackerRank) - Day of the Programmer / C++ (0) | 2020.02.05 |
---|---|
해커랭크(HackerRank) - Migratory Birds / C++ (0) | 2020.02.04 |
해커랭크(HackerRank) - Mini-Max Sum / C++ (0) | 2020.02.04 |
해커랭크(HackerRank) - Birthday Chocolate / C++ (0) | 2020.02.03 |
해커랭크(HackerRank) - Breaking the Records / C++ (0) | 2020.02.03 |
댓글