# Daily Coding Challenge #41

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 171 - A - αlphabet
*/

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

#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
FAST_INP;
char c; cin >> c;
// If α is uppercase, print A; if it is lowercase, print a.
if(isupper(c)) cout <<"A";
else cout <<"a";
return 0;
}

``````

``````/*
AtCoder Beginner Contest 171 - B - Mix Juice
*/

#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,k;
cin >> n >> k;
vector<int> v(n);
for(int i=0;i<n;i++) cin >> v[i];
// sort the input
sort(v.begin(),v.end());
int ans=0;
// sum the first k items up
for(int i=0;i<k;i++){
ans+=v[i];
}
cout << ans << endl;
return 0;
}

``````

``````/*
AtCoder Beginner Contest 171 - C - One Quadrillion and One Dalmatians
*/

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

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

int main()
{
FAST_INP;
long long n;
cin >> n;
int arr[10000];
int i=0;
// convert n to base 26
while(n){
arr[i]=n%26;
n=n/26;
i++;
}
// cant have 0 as A starts at 1
// remove 0
// e.g 100 (base 26) -> 25 26 (base 26)
for (int j=0; j<i-1; j++) {
if (arr[j]<=0) {
// borrow 26
arr[j]+=26;
// substract 1 from next significant bit
arr[j+1]=arr[j+1]-1;
}
}
// 25 26 (base 26) -> YZ
for (int j=i; j>= 0; j--) {
if (arr[j]>0)  cout << char('a'+arr[j]-1);
}
cout << endl;
return 0;
}

``````

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