Date- 25 July 2021
Time – 16:00 IST
Duration – 3 Hours
1. Chess Format
#include <iostream>
using namespace std;
int main() {
int t;
cin>>t;
int a,b;
while(t--)
{
cin>>a>>b;
a=a+b;
if(a<3)
cout<<"1\n";
else if(a<=10)
cout<<"2\n";
else if(a<=60)
cout<<"3\n";
else cout<<"4\n";
}
return 0;
}
2. Food Chain
#include <iostream>
using namespace std;
int main() {
long long t;
cin>>t;
while(t--)
{
long long e,k;
cin>>e>>k;
long long i=0;
while(e!=0)
{
i++;
e=e/k;
}
cout<<i<<"\n";
}
return 0;
}
3. Maximum Array Xor
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t;
cin>>t;
while(t--)
{
int n;
long long k;
cin>>n>>k;
if(k>(long long)pow(2,n-1))
k=(long long)pow(2,n-1);
long long x=(long long)pow(2,n);
x--;
x*=2;
x*=k;
cout<<x<<"\n";
}
return 0;
}
4. Ceiling Sum
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll t;
cin>>t;
while(t--)
{
ll a,b,ans;
cin>>a>>b;
if(a==b)
ans=0;
else if(a>b)
{
a=b-a;
if(a%2==0)
a=a/2+1;
else a=a/2;
ans=a;
}
else
{
b=b-a;
b/=2;
b++;
ans=b;
}
cout<<ans<<"\n";
}
return 0;
}
Click here to join Telegram Group