problem linK:
Discuss:For Square All sides are equal. For Rectangle Opposite Sides are equal. In this problem opposite sides may be any of two from a,b,c,d such as a b or a c . For Quadrangle sum of all three sides are greater than rest of one side
tyr yoursefl before see the code
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long t,l,l1,w,w1,i;
scanf("%lld",&t);
for(i=0;i<t;i++)
{
scanf("%lld %lld %lld %lld",&l,&w,&l1,&w1);
vector<int>vec;
vec.push_back(l);
vec.push_back(l1);
vec.push_back(w);
vec.push_back(w1);
sort(vec.begin(),vec.end());
if((l==w&&w==l1&&l1==w1))
printf("square\n");
else if((vec[0]==vec[1])&&(vec[2]==vec[3]))
printf("rectangle\n");
else if(l<l1+w+w1&&l1<l+w+w1&&w<l+l1+w1&&w1<l+l1+w)
printf("quadrangle\n");
else
printf("banana\n");
}
return 0;
}
Discuss:For Square All sides are equal. For Rectangle Opposite Sides are equal. In this problem opposite sides may be any of two from a,b,c,d such as a b or a c . For Quadrangle sum of all three sides are greater than rest of one side
tyr yoursefl before see the code
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long t,l,l1,w,w1,i;
scanf("%lld",&t);
for(i=0;i<t;i++)
{
scanf("%lld %lld %lld %lld",&l,&w,&l1,&w1);
vector<int>vec;
vec.push_back(l);
vec.push_back(l1);
vec.push_back(w);
vec.push_back(w1);
sort(vec.begin(),vec.end());
if((l==w&&w==l1&&l1==w1))
printf("square\n");
else if((vec[0]==vec[1])&&(vec[2]==vec[3]))
printf("rectangle\n");
else if(l<l1+w+w1&&l1<l+w+w1&&w<l+l1+w1&&w1<l+l1+w)
printf("quadrangle\n");
else
printf("banana\n");
}
return 0;
}
No comments:
Post a Comment