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 that for any positive integer n he can represent fraction as a sum of three distinct positive fractions in form
.
Help Vladik with that, i.e for a given n find three distinct positive integers x, y and z such that . Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding 109.
If there is no such answer, print -1.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
If the answer exists, print 3 distinct numbers x, y and z (1 ≤ x, y, z ≤ 109, x ≠ y, x ≠ z, y ≠ z). Otherwise print -1.
If there are multiple answers, print any of them.
Sample Input
3 7
Sample Output
2 7 42 7 8 56
思路
题意:
给出一个数 n ,问是否存在三个不同的整数 x ,y ,z 满足。
题解:
,因此,我们可以让1/z = 1 / n,剩下的为 1/x + 1/y = 1/n,通过恒等变换可以知道 1/x = ny / (y - n),可以发现,y = n + 1时候,x 必然为整数,因此x = n + n * n,y = n + 1,z = n。需要注意的是,当 n = 1时,x = 2,y = 2,不符合题意。
#include<bits/stdc++.h> using namespace std; int main() { int n; scanf("%d",&n); if (n == 1) printf("-1\n"); else printf("%d %d %d\n",n*n + n,n + 1,n); return 0; }
Codeforces Round #384 (Div. 2) C. 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 Round #384 (Div. 2) A. Vladik and flights 水题
A. Vladik and flights 题目链接 http://codeforces.com/contest/743/problem/A 题面 Vladik is a competitive pr ...
- Codeforces Round #384 (Div. 2) E. Vladik and cards 状压dp
E. Vladik and cards 题目链接 http://codeforces.com/contest/743/problem/E 题面 Vladik was bored on his way ...
- Codeforces Round #384 (Div. 2) 734E Vladik and cards
E. Vladik and cards time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #275 (Div. 2) C - Diverse Permutation (构造)
题目链接:Codeforces Round #275 (Div. 2) C - Diverse Permutation 题意:一串排列1~n.求一个序列当中相邻两项差的绝对值的个数(指绝对值不同的个数 ...
- Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题
Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- Codeforces Round #298 (Div. 2) A、B、C题
题目链接:Codeforces Round #298 (Div. 2) A. Exam An exam for n students will take place in a long and nar ...
- Codeforces Round #384 (Div. 2) //复习状压... 罚时爆炸 BOOM _DONE
不想欠题了..... 多打打CF才知道自己智商不足啊... A. Vladik and flights 给你一个01串 相同之间随便飞 没有费用 不同的飞需要费用为 abs i-j 真是题意杀啊, ...
- Codeforces Round #384 (Div. 2)A,B,C,D
A. Vladik and flights time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
随机推荐
- JS高程5.引用类型(3)Array类型-检测数组
1. instanceof操作符(ECMAScript3) 对于一个网页,或者是一个全局作用域而言,使用instanceof操作符来检测数组就可以得到满意的结果. 语法:if(value instan ...
- JS高程4.变量,作用域和内存问题(1)
1.基本类型和应用类型的值 ECMAScript变量可能包含两种不同数据类型的值: 基本类型值--简单的数据段.(5种基本的数据类型,按值访问,因为可以操作保存在变量中的实际的值.) 引用类型值--多 ...
- 【搬砖】安卓入门(4)- Java开发编程基础--数组
05.01_Java语言基础(数组概述和定义格式说明)(了解) A:为什么要有数组(容器) 为了存储同种数据类型的多个值 B:数组概念 数组是存储同一种数据类型多个元素的集合.也可以看成是一个容器. ...
- iOS 生成二维码
首先先下载生成二维码的支持文件 libqrencode 添加依赖库 CoreGraphics.framework. QuartzCore.framework.AVFoundation.framewor ...
- ckplayer 如何在PC上完美支持 m3u8播放
使用过ckplayer的同学都知道,相对jwplayer等,它非常的容易配置和使用.功能也是基本满足我们的需求的. 一般情况我们都使用普通的视频格式比如mp4,flv等播放,但如果视频文件过大,会加载 ...
- 参加微软Ignite大会有感
很有幸作为MVP参加了本次微软中国的年度技术大会(Ignite).跳出技术领域,这次会议给我最大的感受是态度.这几年不论是开源现有技术,还是黑科技的发布,都给人感觉微软在逐渐变得cool,但是cool ...
- Debain下解决sublime无法输入中文
sublime安装的方法在此不做过多介绍,网上有很多中教程的方式.本文描述在已经安装sublime的前提下如何输入中文. 1.保存下面的代码到文件sublime_imfix.c(位于~目录) #inc ...
- Spark——共享变量
Spark执行不少操作时都依赖于闭包函数的调用,此时如果闭包函数使用到了外部变量驱动程序在使用行动操作时传递到集群中各worker节点任务时就会进行一系列操作: 1.驱动程序使将闭包中使用变量封装成对 ...
- xcode8权限以及相关设置
我们需要打开info.plist文件添加相应权限的说明,否则程序在iOS10上会出现崩溃. 具体如下图: QQ20160914-0.png 注意,添加的时候,末尾不要有空格麦克风权限:Privacy ...
- vs2013 error : cannot open source file "SDKDDKVer.h"
改: 项目属性--常规--工具集--Visual Studio 2013-WindowsXP(v120_xp)