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. 如何让chrome始终运行插件

    使用chrome可能有时候会拦截比如阿里旺旺和腾讯等的登录插件,那么怎么才始终允许,而不需要每次确认呢.下面. 1. 打开Chrome浏览器. 在地址栏中输入 chrome://plugins 回车 ...

  2. [SmartFoxServer概述]SFS2X栈平台

    SmartFoxServer 2X 栈平台 在这有一张SmartFoxServer 2X平台的鸟瞰图,接下来会简要介绍栈中的每个组件. 首先是服务器的核心——网络引擎(代号BitSwarm),它是用以 ...

  3. How to change drive in cygwin

    In DOS you may have been used to D: to change to the D drive. Cygwin provides a mapping of DOS/Windo ...

  4. JSON.parse解析单引号名值对报错

    今天整理代码的时候发现JSON.pare解析时会报了一个错误,而且很难找原因,调试了几分钟没有成功,猜测可能是单双引号引起的错误.修改了单双引号后程序正常运行了,现在记录下这个bug. 关于JSON. ...

  5. poj 1021矩阵平移装换后是否为同一个矩阵

    2D-Nim Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3081   Accepted: 1398 Descriptio ...

  6. 解决JSON.stringify()在IE10下无法使用的问题

    今天在IE10下遇到了JSON.stringify()无法使用的问题,错误信息为:'JSON' is undefined . 开始以为是没有添加json2.js引用的原因.后来发现,其他地方也没添加j ...

  7. IP协议

    因特网协议(Internet Protocol, IP)是Internet的核心协议之一, 工作在网络层.IP协议提供节点间的寻址,路由以及顺序控制, 流量控制等服务. IP协议分为IPv4和IPv6 ...

  8. 微软BI 之SSIS 系列 - ETL 转换时关于 Code Page (1252 and 936) 转换错误的原因和解决方法

    开篇介绍 最近经常碰到在 ETL 练习中出现这种转换失败的问题,试了多种方式,同样的代码同样的源结构和表结构但是一直不能成功执行,包报错.一般有这么几种错误: Error at DST_LOAD_DA ...

  9. 冲刺阶段 day 4

    day4 项目进展 今天上完软件工程后我们便聚在宿舍,总结了一下昨天的工作,讨论完成了昨天未完成的 注册功能,然后趁热打铁,构建了学生管理这部分的窗体搭建及部分代码的编写. 存在的问题 代码记不得.在 ...

  10. Nim教程【二】

    第一篇教程1秒内就被管理员从首页踢掉了 管理员嫌内容太少,没有含金量,这次多写一些. 这应该是国内第一个关于Nim入门的系列教程 好,闲话休提,言归正传 Nim介绍 Nim代码会编译成C语言的代码,再 ...