707C Codeforces - Pythagorean Triples





Solution in c++

#include <iostream>
#include <iomanip>
using namespace std;

long long int a;

int main()
{
    cin>>a;
    if(a<=2)cout<<-1;
    else if(a==1000000000)cout<<"1250000000 750000000\n";
    else if(a%2)
        cout<<fixed<<setprecision(0)<<(a*a-1)/2<<" "<<(a*a+1)/2<<"\n";
    else
         cout<<fixed<<setprecision(0)<<a*a/4+1<<" "<<a*a/4-1<<"\n";

    return 0;
}

Share on Google Plus

About Mohamed Sobhi

My name is Mo.Sobhy ,I study at School excelling high school in Ain Shams ,Cairo
My hobbies is programming ,and web development ,playing chess and writing horror stories.
    Blogger Comment
    Facebook Comment

0 التعليقات:

إرسال تعليق