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. leetcode 刷题日志 2018-3-28

    树: 404. 左叶子之和 求所有左叶子结点之和 . 递归法 分析:递归法遍历结点,找左叶子结点 空指针判断 有左子节点?是叶子结点?是的话更新value的值 int sumOfLeftLeaves( ...

  2. PowerDesigner16 修改表或表的字段Name的时候不让Code不自动跟着变

    在修改表或表的字段Name的时候不让Code不自动跟着变,设置如下: tools-> General   Options-> Dialog 去掉勾选 Name To Code mirror ...

  3. 希尔排序Shell sort

    希尔排序Shell Sort是基于插入排序的一种改进,同样分成两部分, 第一部分,希尔排序介绍 第二部分,如何选取关键字,选取关键字是希尔排序的关键 第一块希尔排序介绍 准备待排数组[6 2 4 1 ...

  4. bzoj 4034: [HAOI2015]树上操作——树链剖分

    Description 有一棵点数为 N 的树,以点 1 为根,且树点有边权.然后有 M 个 操作,分为三种: 操作 1 :把某个节点 x 的点权增加 a . 操作 2 :把某个节点 x 为根的子树中 ...

  5. 【51NOD-0】1049 最大子段和

    [算法]DP [题解]开long long…… #include<cstdio> #include<algorithm> #include<cstring> usi ...

  6. 【转载】Quick 中的触摸事件

    原文地址 http://cn.cocos2d-x.org/article/index?type=quick_doc&url=/doc/cocos-docs-master/manual/fram ...

  7. 当你启动Redis的时候,Redis做了什么

    直奔主题,当启动Redis的时候,Redis执行了哪些操作? 假设Redis安装在了/usr/local/目录下,那么启动Redis是通过执行/usr/local/bin/redis-server - ...

  8. 深入理解Spring MVC(山东数漫江湖)

    初始工程 使用Spring Boot和web,thymeleaf的starter来设置初始工程.xml配置如下: <parent>   <groupId>org.springf ...

  9. bzoj 1406 数论

    首先问题的意思就是在找出n以内的所有x^2%n=1的数,那么我们可以得到(x+1)(x-1)=y*n,那么我们知道n|(x+1)(x-1),我们设n=a*b,那么我们对于任意的a,我们满足n%a==0 ...

  10. Centos修改镜像为国内的阿里云源或者163源等国内源

    阿里安装软件镜像源 阿里云Linux安装镜像源地址:http://mirrors.aliyun.com/ 第一步:备份你的原镜像文件,以免出错后可以恢复. mv /etc/yum.repos.d/Ce ...