Vladik and fractions CodeForces - 743C 思维

vj

比较有意思的思维题,不过在巨巨们眼里都是小学六年级题。

先看式子 1/x + 1/y + 1/z = 2/n ,n分子是2,我们想办法变成1,所以让z=n,这样就消去变成了 1/x + 1/y = 1/n ,而我们知道 1/n可以表示成 1/(n+1) + 1/(n*(n+1)) 这样 x = n + 1 , y = n * (n+1)。
这样构造出来答案为x=n,y=n+1,z=n×(n+1)。显然 n<=1 无解。

#pragma GCC optimize(2)
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<cmath>
#include<cctype>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<sstream>
#define X first
#define Y second
#define L (u<<1)
#define R (u<<1|1)
#define Mid (tr[u].l+tr[u].r>>1)
#define Len(u) (tr[u].r-tr[u].l+1)
#define pb push_back
#define mk make_pair
using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

const int N=1000010,mod=1e9+7,INF=0x3f3f3f3f;
const double eps=1e-6;

int n;

int main()
{
//	ios::sync_with_stdio(false);
//	cin.tie(0);

    scanf("%d",&n);
    if(n<=1) puts("-1");
    else printf("%d %d %d\n",n,n+1,n*(n+1));    


	return 0;
}
/*

*/









猜你喜欢

转载自blog.csdn.net/DaNIelLAk/article/details/108354952
今日推荐