数学【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 ...
随机推荐
- [USACO06NOV] Roadblocks
https://www.luogu.org/problem/show?pid=2865 题目描述 Bessie has moved to a small farm and sometimes enjo ...
- (转) jsp学习笔记
fromhttp://www.cnblogs.com/tao975/p/4445070.html 什么是JSP JSP的优势 JSP的劣势 JSP与PHP的比较 JSP工作原理 JSP的九大内置对象 ...
- VirtualBox4.3.12 安装ubuntu 14.04 分辨率过小(600*480)问题的解决方法
作为.net程序员,一直都跟windows系统打交道,在同事的影响下,今天安装了Ubuntu 14. 安装完系统就遇到了这个麻烦事,找了好久才解决,因此记录下来,或许对和我一样的Ubuntu新手有帮助 ...
- intellj idea点击导航栏打开的一个类,怎么才能定位到类的目录
- Item 6 消除过期的对象引用
过期对象引用没有清理掉,会导致内存泄漏.对于没有用到的对象引用,可以置空,这是一种做法.而最好的做法是,把保存对象引用的变量清理掉,多用局部变量. 什么是内存泄漏? 在Java中,对象的内存空间回 ...
- 【POJ】2947 Widget Factory(高斯消元)
http://poj.org/problem?id=2947 各种逗啊..还好1a了.. 题意我就不说了,百度一大把. 转换为mod的方程组,即 (x[1,1]*a[1])+(x[1,2]*a[2]) ...
- 【HNOI】矩阵染色 数论
[题目描述]一个2*i的矩阵,一共有m种颜色,相邻两个格子颜色不能相同,m种颜色不必都用上,f[i]表示这个答案,求Σf[i]*(2*i)^m (1<=i<=n)%p. [数据范围] 20 ...
- Android控件——TextView,EditText
TextView: 显示文本控件 EditText 输入文本框 1.TextView常用属性:
- Java多线程学习(四)等待/通知(wait/notify)机制
转载请备注地址:https://blog.csdn.net/qq_34337272/article/details/79690279 系列文章传送门: Java多线程学习(一)Java多线程入门 Ja ...
- python模块 zipfile
zipfile是python里用来做zip格式编码的压缩和解压缩的,由于是很常见的zip格式,所以这个模块使用频率也是比较高的zipfile里有两个非常重要的class, 分别是ZipFile和Zip ...