Thursday, 7 September 2017

OjLight Problem 1053 - Higher Math Solution (C++)

Problem: OjLight Problem 1053 - Higher Math

Solution:

This is the simplest problem I ever had, just implement the given formulas! However, it does take me some time to write.

Code:

#include <bits/stdc++.h>
using namespace std;
main(){
long long n,a,b,c,f,g;
cin>>n;
for(int i=1;i<=n;i++){
        cin>>a>>b>>c;
if(a>b && a>c)
{
    f= a*a;
    g=(b*b)+(c*c);

}
else if(b>a&&b>c){
    f= (b*b);
    g= a*a+c*c;
}
else if(c>a&& c>b){
    f=c*c;
    g=a*a+b*b;
}
(f==g?cout<<"Case "<<i<<":"<<" yes"<<endl:cout<<"Case "<<i<<":"<<" no"<<endl);
}
return 0;
}



No comments:

Post a Comment

Spoj Problem ACMCEG2C - Pick the candies (C++)

  The problem link may be found here.       Explanation: Use Deque to keep track of elements of the variety of candies. If i is gre...