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.

You may like these posts

  • 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…
  • ProblemGru 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 aw…
  • 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…
  • ProblemWrite 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 FormatFirst l…
  •  ProblemIn a coding contest, there are prizes for the top rankers. The prize scheme is as follows:Top 10 participants receive rupees X each.Participants with rank 11 to 100 (b…
  • ProblemChef is a big fan of Coldplay. Every Sunday, he will drive to a park taking MM minutes to reach there, and during the ride he will play a single song on a loop. Today, he ha…

Post a Comment