Title Description
Given right-angled triangle in which the length of one side of n, is to construct your task remaining two sides, so that it can form three sides of a right triangle.
Enter a description:
An integer n.
Output Description:
The two other edges b, c. The answer is not unique, as long as any set of output that is reasonable, if you can not make construction output -1.
Example 1
Entry
3
Export
4 5
Example 2
Entry
4
Export
3 5
Remarks:
0 <= n-<= 1E9
. 1 <= B, C <= 1e18
n-, B, C are integers
ac Code:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,b,c,t;
int main(){
cin>>n;
if(n>1&&n%2==1){
t=(n-1)/2;
b=2*t*t+2*t;
c=b+1;
cout<<b<<" "<<c<<endl;
}
else if(n>=4&&n%2==0){
t=n/2;
b=t*t-1;
c=t*t+1;
cout<<b<<" "<<c<<endl;
}
else
cout<<"-1"<<endl;
return 0;
}
Ideas:
Remember just fine