C. Vladik and fractions

题目链接

http://codeforces.com/contest/743/problem/C

题面

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.

输入

The single line contains single integer n (1 ≤ n ≤ 104).

输出

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.

样例输入

3

样例输出

2 7 42

题意

给你n,让你找到一个x,y,z,使得2/n = 1/x+1/y+1/z

题解

n=1的时候无解,否则可以构造出x=n,y=n+1,z=n(n+1)

代码

#include<bits/stdc++.h>
using namespace std; long long n;
int main()
{
cin>>n;
if(n==1)cout<<"-1"<<endl;
else cout<<n<<" "<<n+1<<" "<<n*(n+1)<<endl;
}

Codeforces Round #384 (Div. 2) C. Vladik and fractions 构造题的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. Codeforces Round #275 (Div. 2) C - Diverse Permutation (构造)

    题目链接:Codeforces Round #275 (Div. 2) C - Diverse Permutation 题意:一串排列1~n.求一个序列当中相邻两项差的绝对值的个数(指绝对值不同的个数 ...

  6. 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  ...

  7. 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 ...

  8. Codeforces Round #384 (Div. 2) //复习状压... 罚时爆炸 BOOM _DONE

    不想欠题了..... 多打打CF才知道自己智商不足啊... A. Vladik and flights 给你一个01串  相同之间随便飞 没有费用 不同的飞需要费用为  abs i-j 真是题意杀啊, ...

  9. 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 ...

随机推荐

  1. Android开源框架——Picasso

    开篇——介绍Picasso (Picasso是什么?)Picasso:A Powerfull Image Downloading and Caching Library for Android,即An ...

  2. linux 下 jdk+tomcat+mysql 的 jsp 环境搭建

    JDK 在 linux 下安装 1.          把安装文件放在 /opt 下,并执行 [root@localhost opt]# ./jdk-1_5_0_06-linux-i586.bin 并 ...

  3. tomee 第一个 远程调用 Session Bean

    参考文档 http://tomee.apache.org/ http://download.oracle.com/otndocs/jcp/ejb-3.1-pfd-oth-JSpec/ http://d ...

  4. 取td里面的内容

    var rowLength = document.getElementById("table名字").rows.length;   for(var i=0;i<rowLeng ...

  5. linux-01Red Hat Enterprise Linux 7(RHEL7)配置静态IP地址

    为方便在学习linux readhat7,在本地安装安装了虚拟机.为能够用win7连接虚拟机的linux远程客户端操作,则需要虚拟机和win本地的网络互通: 操作如下:1.本地配置ip地址 : 2.验 ...

  6. 解决阿里云SLB无法添加https证书的问题

    私钥是在Linux中通过下面的openssl命令生成的: openssl req -new -newkey rsa:2048 -nodes -keyout cnblogs.key -out cnblo ...

  7. 真实世界:使用WCF扩展在方法调用前初始化环境

    OperationInvoker 介绍 OperationInvoker 是 WCF 运行时模型中在调用最终用户代码前的最后一个扩展点,OperationInvoker 负责最终调用 Service ...

  8. Wix 安装部署(五) Bootstrapper 捆绑安装

    Wix的xml配置确实很费劲,忍不住有点像吐槽一下,前四篇完成的功能在Windows Installer中通过配置能很快的弄出来.可惜有很多加了锁的功能在InstallShield Limited E ...

  9. vim和tmux主题颜色不一致问题

        没开tmux时使用vim 以及 开了tmux后使用vim 主题颜色不一致.随便打开一个.py文件,发现着色较深,非常影响阅读.   开始在.tmux.conf 中设置set -g defaul ...

  10. 使用UEditor无法SetContent的问题

    无法SetContent是因为 <script id="txtContent" name="txtContent" type="text/pla ...