Description

请找出一组合法的解使得\(\frac {1}{x} + \frac{1}{y} + \frac {1}{z} = \frac {2}{n}\)成立 其中\(x,y,z\)为正整数并且互不相同

Input

一个整数\(n\)

Output

一组合法的解\(x, y ,z\),用空格隔开 若不存在合法的解,输出\(-1\)

首先,最先容易想到的是令\(x,y,z\)其中一个数为\(n\),那么我们现在的问题就变成了求解这个式子。

\[\frac{1}{x}+\frac{1}{y}=\frac{1}{n}
\]

如果你是一个学过高中数学的人,

你会发现,这可以裂项(是叫这个吧?喵喵喵?)

\[\frac{1}{n}=\frac{1}{n+1}+\frac{1}{n(n+1)}
\]

按照常理来说,一般人都会证明一下,但是我不会证明啊!!

所以其实刚开始我没有意识到是裂项

然后,先观察样例。

当\(n=7\)的时候三个解分别为\(7,8,56\),嗯?暗示着我什么?

接下来代入\(n,n+1.n(n+1)\)到式子中,貌似是正解?

交上去Wa了?,结果发现没有判断无解。

无解条件:$n=1 \(或\)n=0$

如果\(n=1\)的时候的话,显然,三个以整数为分母(且互不相同),分子为\(1\)的分数,相加不可能大于等于\(2\)。

最大是\(1+\frac{1}{2}+\frac{1}{3}\)。

还有\(n=0\),这个分数无意义,还求什么解。

代码

#include<cstdio>
#define lo long long
#define R register using namespace std; lo n;
int main()
{
scanf("%lld",&n);
if(n==1 or n==0)puts("-1");
else printf("%lld %lld %lld",n,n+1,n*(n+1));
}

数学【CF743C】Vladik and fractions的更多相关文章

  1. Codeforces Round #384 (Div. 2) C. Vladik and fractions 构造题

    C. Vladik and fractions 题目链接 http://codeforces.com/contest/743/problem/C 题面 Vladik and Chloe decided ...

  2. Codeforces 743C - Vladik and fractions (构造)

    Codeforces Round #384 (Div. 2) 题目链接:Vladik and fractions Vladik and Chloe decided to determine who o ...

  3. [codeforces743C]:Vladik and fractions(数学)

    题目传送门 题目描述 请找出一组合法解使得$\frac{1}{x}+\frac{1}{y}+\frac{1}{z}=\frac{2}{n}$成立. 其中$x,y,z$为正整数且互不相同. 输入格式 一 ...

  4. Codeforces Round #384 (Div. 2) C. Vladik and fractions(构造题)

    传送门 Description Vladik and Chloe decided to determine who of them is better at math. Vladik claimed ...

  5. 【44.64%】【codeforces 743C】Vladik and fractions

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  6. vjudge I - Vladik and fractions 一道小学生的提。

    原题链接:https://vjudge.net/contest/331993#problem/I Vladik and Chloe decided to determine who of them i ...

  7. CodeForces 743C Vladik and fractions (数论)

    题意:给定n,求三个不同的数满足,2/n = 1/x + 1/y + 1/z. 析:首先1是没有解的,然后其他解都可以这样来表示 1/n, 1/(n+1), 1/(n*(n+1)),这三个解. 代码如 ...

  8. CF C. Vladik and fractions——构造题

    题目 构造一组 $x, y, z$,使得对于给定的 $n$,满足 $\frac{1}{x}  + \frac{1}{y} + \frac{1}{z} =  \frac{2}{n}$. 分析: 样例二已 ...

  9. CF2.C

    C. Vladik and fractions time limit per test 1 second memory limit per test 256 megabytes input stand ...

随机推荐

  1. 51Nod 1087 1 10 100 1000 | 数学

    Input示例 3 1 2 3 Output示例 1 1 0 #include "bits/stdc++.h" using namespace std; #define LL lo ...

  2. [Luogu 2604] ZJOI2010 网络扩容

    [Luogu 2604] ZJOI2010 网络扩容 第一问直接最大流. 第二问,添加一遍带费用的边,边权 INF,超级源点连源点一条容量为 \(k\) 的边来限流,跑费用流. 大约是第一次用 nam ...

  3. css 实现元素水平垂直居中总结5中方法

    个人总结,如有错误请指出,有好的建议请留言.o(^▽^)o 一.margin:0 auto:text-align:center:line-height方法 <div id="divAu ...

  4. HDU 2577 How to Type (字符串处理)

    题目链接 Problem Description Pirates have finished developing the typing software. He called Cathy to te ...

  5. VMware Workstation Pro 14 序列号

    VMware Workstation Pro 14 序列号: AA702-81D8N-0817Y-75PQT-Q70A4 YC592-8VF55-M81AZ-FWW5T-WVRV0 FC78K-FKE ...

  6. C# 文件操作常用方法总结

    需引用 System.IO Path为绝对路径 检测指定目录是否存在 Directory.Exists(Path) 创建目录 Directory.CreateDirectory(Path) 删除目录 ...

  7. Ubuntu 修改IP地址

    Ubuntu 修改IP地址1.ubuntu系统修改IP地址:sudo vim /etc/network/interfacesauto eth0iface eth0 inet staticaddress ...

  8. Which cryptsetup

    Which cryptsetup Rpm –qf ‘which cryptsetup’ 安装加密工具: 设置加密分区 Crptsetup luksFormat Echo –n “xuegod123”  ...

  9. 跟踪内核启动过程CONFIG_DEBUG_LL【转自】

    转自:http://bbs.chinaunix.net/thread-3642079-1-1.html 最近在调试Linux内核,跟踪启动过程.发现在没有turn on mmu之前,可以使用物理地址, ...

  10. 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6153 A Secret KMP,思维

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6153 题意:给了串s和t,要求每个t的后缀在在s中的出现次数,然后每个次数乘上对应长度求和. 解法:关 ...