数学【CF743C】Vladik and fractions
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\),那么我们现在的问题就变成了求解这个式子。
\]
如果你是一个学过高中数学的人,
你会发现,这可以裂项(是叫这个吧?喵喵喵?)
则
\]
按照常理来说,一般人都会证明一下,但是我不会证明啊!!
所以其实刚开始我没有意识到是裂项
然后,先观察样例。
当\(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的更多相关文章
- Codeforces Round #384 (Div. 2) C. Vladik and fractions 构造题
C. Vladik and fractions 题目链接 http://codeforces.com/contest/743/problem/C 题面 Vladik and Chloe decided ...
- Codeforces 743C - Vladik and fractions (构造)
Codeforces Round #384 (Div. 2) 题目链接:Vladik and fractions Vladik and Chloe decided to determine who o ...
- [codeforces743C]:Vladik and fractions(数学)
题目传送门 题目描述 请找出一组合法解使得$\frac{1}{x}+\frac{1}{y}+\frac{1}{z}=\frac{2}{n}$成立. 其中$x,y,z$为正整数且互不相同. 输入格式 一 ...
- 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 ...
- 【44.64%】【codeforces 743C】Vladik and fractions
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- vjudge I - Vladik and fractions 一道小学生的提。
原题链接:https://vjudge.net/contest/331993#problem/I Vladik and Chloe decided to determine who of them i ...
- CodeForces 743C Vladik and fractions (数论)
题意:给定n,求三个不同的数满足,2/n = 1/x + 1/y + 1/z. 析:首先1是没有解的,然后其他解都可以这样来表示 1/n, 1/(n+1), 1/(n*(n+1)),这三个解. 代码如 ...
- CF C. Vladik and fractions——构造题
题目 构造一组 $x, y, z$,使得对于给定的 $n$,满足 $\frac{1}{x} + \frac{1}{y} + \frac{1}{z} = \frac{2}{n}$. 分析: 样例二已 ...
- CF2.C
C. Vladik and fractions time limit per test 1 second memory limit per test 256 megabytes input stand ...
随机推荐
- Sandglass
题目描述 We have a sandglass consisting of two bulbs, bulb A and bulb B. These bulbs contain some amount ...
- 与http协作的web服务器、http首部(第五章、第六章)
第五章 与http协作的web服务器 1.用单台虚拟主机实现多个域名 通过域名访问主机,经过DNS解析成ip地址,反向代理,可以代理多台服务器,正向代理则相反,代理客户端 2.通信数据转化程序:代理. ...
- HDU2031 进制转换
#include <iostream> #include "string" #include "cstdio" #include "cst ...
- 【BZOJ4236】JOIOJI [DP]
JOIOJI Time Limit: 10 Sec Memory Limit: 256 MB[Submit][Status][Discuss] Description JOIOJI桑是JOI君的叔叔 ...
- 【BZOJ4817】【SDOI2017】树点涂色 [LCT][线段树]
树点涂色 Time Limit: 10 Sec Memory Limit: 128 MB[Submit][Status][Discuss] Description Bob有一棵n个点的有根树,其中1 ...
- node起本地服务器以及实现代理,前端接口转发
上一篇文章写了使用docker来做nginx镜像实现本地的页面代理以及接口转发,但是需要下载docker,这个对于很多人来说还是显得比较麻烦,于是这个文章就是介绍如何只用node就可以代理本地的页面和 ...
- hdu 1070 Milk(贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1070 Milk Time Limit: 2000/1000 MS (Java/Others) M ...
- rabbitmq之核心构架和原理总结(四)
前言 前面博文已经将安装配置和站点管理介绍了,现在开始正式学习rabbitmq的使用了: rabbitMQ的构架 rabbitmq作为消息队列,一条消息从发布到订阅消费的完整流程为: 消息 --> ...
- ZZ:Solaris 10 软件包分析
ZZ:Solaris 10 软件包分析 http://blog.chinaunix.net/uid-22759617-id-276756.html # Last updated: 2006-02-14 ...
- 转 白话解析:一致性哈希算法 consistent hashing
摘要: 本文首先以一个经典的分布式缓存的应用场景为铺垫,在了解了这个应用场景之后,生动而又不失风趣地介绍了一致性哈希算法,同时也明确给出了一致性哈希算法的优点.存在的问题及其解决办法. 声明与致谢: ...