codeforces-743C-math

题目大意:给定n,求满足2/n=1/x+1/y+1/z的x,y,z的值

题目解析:想到1/a+1/(a+1)+1/(a*a+a)=2/a,所以我们只要令x=a,y=a+1,z=a*a+a即可,注意n=1的时候y=z不可以;

AC代码:

#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
const int inf=0x3fffffff;
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		if(n==1)
		{
			printf("-1\n");
			continue;
		}
		int a,b,c;
		a=n;
		b=n+1;
		c=n*(n+1);
		printf("%d %d %d\n",a,b,c);
	}
	return 0;
}



你可能感兴趣的:(math)