1.Car Trip
C++ solution
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int t;
cin>>t;
while(t–){
long long int x;
cin>>x;
if(x<300)
x=300;
cout<<x*10<<endl;
}
return 0;
}
2.Greater Average
Solution in C++:
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int t;
cin>>t;
while(t–){
long long a,b,c;
cin>>a>>b>>c;
double av;
av = (a+b)*1.0/2;
if(av>c)
cout<<“YES”<<endl;
else
cout<<“NO”<<endl;
}
return 0;
}
3.Solution in C++:
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int t;
cin>>t;
while(t–){
long long w,x,y,z;
cin>>w>>x>>y>>z;
if(w==x)
cout<<“yes”<<endl;
else if(w==y)
cout<<“yes”<<endl;
else if(w==z)
cout<<“yes”<<endl;
else if(w==(x+y))
cout<<“yes”<<endl;
else if(w==(y+z))
cout<<“yes”<<endl;
else if(w==(x+z))
cout<<“yes”<<endl;
else if(w==(x+y+z))
cout<<“yes”<<endl;
else
cout<<“no”<<endl;
}
return 0;
}
4.
4. Odd Pairs
Solution in C++:
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int t;
cin>>t;
while(t–){
long long int n,odd,even;
cin>>n;
even= n/2;
odd = n-even;
cout<<2*even*odd<<endl;
}
return 0;
}
5. Make A and B equal
Solution in C++:
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int t;
cin>>t;
while(t–){
long long int n,i,sum=0,x,c,mx=0;
cin>>n;
vector<long long int> v;
for(i=0;i<n;i++){
cin>>x;
v.push_back(x);
}
for(i=0;i<n;i++){
cin>>x;
c=v[i]-x;
sum=sum+v[i]-x;
if(c>0)
mx=mx+c;
}
if(sum==0)
cout<<mx<<endl;
else
cout<<-1<<endl;
}
return 0;
}