Codeforces 707C. Pythagorean Triples Solution

Solve in C++:

  1. ///**********ALLAH IS ALMIGHTY************///
  2. ///AH Tonmoy
  3. ///Department of CSE
  4. ///Islamic University,Bangladesh
  5. #include <iostream>
  6. using namespace std;
  7. int main()
  8. {
  9. long long int n;
  10. while(cin>>n)
  11. {
  12. if(n<3)
  13. cout<<"-1"<<endl;
  14. else
  15. {
  16. if(n%2==1)
  17. {
  18. cout<<((n*n)-1)/2<<" "<<((n*n)+1)/2<<endl;
  19. }
  20. else
  21. {
  22. cout<<((n*n)/4)-1<<" "<<((n*n)/4)+1<<endl;
  23. }
  24. }
  25. }
  26.  
  27. }

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.