Pythagorean Triples CodeForces - 707C 【数学】

勾股数公式

 1 #include<bits\stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 int main() {
 5     ll n;
 6     cin>>n;
 7     if(n<3)cout<<-1;
 8     else if(n%2==0){
 9         cout<<(n*n/4-1)<<" "<<(n*n/4+1);
10     }
11     else{
12         cout<<(n*n-1)/2<<" "<<(n*n+1)/2;
13     }
14     return 0;
15 }

 

posted @ 2018-03-09 10:16  晓风微微  阅读(131)  评论(0编辑  收藏  举报