Lorem ipsum dolor sit amet, consectetur adipiscing elit. Test link

Area OR Perimeter : AREAPERI | CodeChef Solution


Problem

Write a program to obtain length (L)(L) and breadth (B)(B) of a rectangle and check whether its area is greater or perimeter is greater or both are equal.

Input Format

  • First line will contain T, number of test cases. Then the test cases follow.
  • Each test case contains of a single line of input, two integers X and Y - the prize for top 10 rankers and the prize for ranks 11 to 100 respectively.

Output Format

Output 2 lines.

In the first line print "Area" if area is greater otherwise print "Peri" and if they are equal print "Eq".(Without quotes).

In the second line print the calculated area or perimeter (whichever is greater or anyone if it is equal).


Constraints

  • 1 \leq B \leq 1000
  • 1 \leq T \leq 1000

Sample 1:

Input
Output
1
2
Peri
6

Explanation:

Area = 1 * 2 = 2
Peri = 2(1 + 2) = 6
Since Perimeter is greater than Area, hence the output is
Peri
6

Solution

#include <iostream>
using namespace std;

// Solution from : Code Radius [ https://radiuscode.blogspot.com/ ]

int main() {
// your code goes here
int l,b,p,a;
cin>>l;
cin>>b;
p=2*(l+b);
a=l*b;
if(p>a)
{
cout<<"Peri"<<endl;
cout<<p;
}
else if(p<a)
{
cout<<"Area"<<endl;
cout<<a;
}
else if(p==a)
{
cout<<"Eq"<<endl;
cout<<p;
}

return 0;

}

Please First Try to Solve Problem by Yourself.

إرسال تعليق

© Code Radius 2. All rights reserved. Distributed by Techy Darshan Distributed by Pro Templates