Vladik and fractions CodeForces - 743C 思维

一道关于思维的趣味编程题,将1/x + 1/y + 1/z = 2/n 转化为1/x + 1/y = 1/n,并通过1/n = 1/(n+1) + 1/(n*(n+1))求解,得出x=n+1, y=n*(n+1), z=n的解,条件为n>1。" 132453747,14311535,himall3.0商城源码:订单售后状态检查与物流更新,"['Java开发', '电商系统', '订单管理', '物流跟踪', 'API接口']

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;
}
/*

*/









评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值