# Daily Coding Challenge #60

This is a series of Daily Coding Challenge. Each day I show a few solutions written in C++. The questions are from coding practice/contest sites such as HackerRank, LeetCode, Codeforces, Atcoder and etc.

/*
AIsing Programming Contest 2020 - A - Number of Multiples
*/

#include <bits/stdc++.h>
using namespace std;

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
FAST_INP;
int l,r,d;
cin >> l >> r>> d;
int ans=0;
// check if i can be divided by d without a remainder
for(int i=l;i<=r;i++){
if(i%d==0) ans++;
}
cout << ans;
return 0;
}


/*
AIsing Programming Contest 2020 - B - An Odd Problem
*/

#include <bits/stdc++.h>
using namespace std;

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
FAST_INP;
int n;
cin >> n;
int ans=0;
for(int i=1;i<=n;i++) {
int a;
cin >> a;
//      check if the assigned number, i, is odd, and
//      check if the written integer is odd
if((i&1)&&(a&1)) ans++;
}
cout << ans;
return 0;
}


/*
AIsing Programming Contest 2020 - C - XYZ Triplets
*/

#include <bits/stdc++.h>
using namespace std;

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)

int main()
{
FAST_INP;
int n;
cin >> n;
unordered_map<int,int> ans(n);
// pre-build the ans map
// note that N<= 10^4
for(int x=1;x<=105;x++){
for(int y=1;y<=105;y++){
for(int z=1;z<=105;z++){
int k = (x*x)+(y*y)+(z*z)+(x*y)+(y*z)+(z*x);
if( k < 10005 ) {
ans[k]++;
}
}
}
}
for(int i=1;i<=n;i++) cout << ans[i] << "\n";
return 0;
}


The source code is available in corresponding repo below. Star and watch for timely updates!

## wingkwong / atcoder

Posted on by:

### Wing-Kam

Consultant by day. Developer by night. AWS certified. Exploring #CloudNative currently.