# Daily Coding Challenge #48

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.

``````/*
AtCoder Beginner Contest 172 - A - Calc
*/

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

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
FAST_INP;
int a;
cin >> a;
// print the value a+a^2+a^3
cout << ((a) + (a*a) + (a*a*a)) << "\n";
return 0;
}

``````

``````/*
AtCoder Beginner Contest 172 - B - Minor Change
*/

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

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
FAST_INP;
string s,t;
cin >> s >> t;
int n = (int)s.size();
int ans=0;
// choose one character of S and replace it with a different character
for(int i=0;i<n;i++){
if(s[i]!=t[i]) ans++;
}
cout << ans << "\n";
return 0;
}

``````

``````/*
AtCoder Beginner Contest 172 - D - Sum of Divisors
*/

#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;
vector<long long> d(n+1,0);
long long ans=0;
for(int i=1;i<=n;i++){
for (int j=1;j*i<=n;j++) {
// d(X) be the number of positive divisors of X .
d[i*j]++;
}
}

for(int i=1;i<=n;i++){
// find ∑N K=1 K*d(K)
ans+=i*d[i];
}

cout << ans;
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.