Editorial for A vs B

PROBLEM LINK:CodeChef: Practical coding for everyone

Author: Abhishek Yadav
Tester: Abhishek Yadav
Editorialist: Abhishek Yadav

DIFFICULTY:

CAKEWALK

PREREQUISITES:

Math

PROBLEM:

You are given the marks of student A and B out of 500. you have to calculate their percentage. if the percentage of student A is greater then B the print “A” without quotes else print “B”.

QUICK EXPLANATION:

In this question we have to find who will have more percentage A or B.
if A has more percentage then B the we have to print A else B.

EXPLANATION:

Here in this question there is no need to find percentage of both the students we just have to check which student has more marks. As we know that higher is the marks higher is the percentage that it.
The student with more marks is the winner.
If both the students have equal marks then also the winner is A. as described in question also.

SOLUTIONS:

Setter's Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int a,b;
cin>>a>>b;
if(a>b)
{
cout<<“A”<<“\n”;
}
else
{
cout<<“B”<<“\n”;
}
}
}

Tester's Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int a,b;
cin>>a>>b;
if(a>b)
{
cout<<“A”<<“\n”;
}
else
{
cout<<“B”<<“\n”;
}
}
}

Editorialist's Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int a,b;
cin>>a>>b;
if(a>b)
{
cout<<“A”<<“\n”;
}
else
{
cout<<“B”<<“\n”;
}
}
}