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

Area OR Perimeter : AREAPERI | CodeChef Solution

1 min read


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.

قد تُعجبك هذه المشاركات

  • Problem Gru has not been in the limelight for a long time and is, therefore, planning something particularly nefarious. Frustrated by his minions' incapability which has kept him…
  • ProblemChef has NN slippers, LL of which are left slippers and the rest are right slippers. Slippers must always be sold in pairs, where each pair contains one left and one right s…
  • ProblemAlice and Bob are meeting after a long time. As usual they love to play some math games. This times Alice takes the call and decides the game. The game is very simple, Alice…
  • ProblemYou're given an integer N. Write a program to calculate the sum of all the digits of N.Input FormatThe first line contains an integer T, the total number of testcases. Then …
  • post 5…
  • ProblemYou and your friend are playing a game with hoops. There are NN hoops (where NN is odd) in a row. You jump into hoop 11, and your friend jumps into hoop NN. Then you jump in…

إرسال تعليق