题目链接
http://codeforces.com/contest/743/problem/C
思路
要使
2n=1x+1y+1z
且
x≠y≠z
那么我们可以考虑令
z=n
接下来就只需要构造
1n=1x+1y
。可以解得:
x=nyy−n
,并且
x
和
很显然,可以令
y=n+1
,那么
x=ny
。
特殊情况:
n=1
的时候无解
代码
#include <bits/stdc++.h>
using namespace std;
inline int in() {int x; scanf("%d", &x); return x;}
#define pr(x) {cout << #x << ' ' << x << endl;}
int n, x, y, z;
int main() {
n = in();
if (n == 1) { cout << -1 << endl; return 0; }
y = n + 1;
x = n * y;
z = n;
cout << x << ' ' << y << ' ' << z << endl;
return 0;
}

本文针对Codeforces竞赛中一道题目提供了详细的解题思路与代码实现。通过对特定数学关系的利用,给出了构造性的解答方案。
445

被折叠的 条评论
为什么被折叠?



