一个数的(勾股数)组

大概

一开始还以为是勾股 的数组呢、、
题目-->codeforces
求一个数所在的任意勾股数组
算了,不胡扯扯了,还是看原博客吧
应该是中国人写的,翻译友好

#include <iostream>
#define ll long long
using namespace std;
int main() {
	ll n,a,b;
	cin>>n;
	if(n==1||n==2) {
		puts("-1");
		return 0;
	}
	if(n&1) {
		n=n*n-1;
		a=n/2;
		b=a+1;
	} else {
		n=n*n/2-2;
		a=n/2;
		b=a+2;
	}
	cout<<a<<" "<<b<<"\n";
	return 0;
}
posted @ 2019-01-13 20:13  ComplexPug  阅读(214)  评论(0编辑  收藏  举报