Codeforces Round #384 (Div. 2) C. Vladik and fractions 构造题
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 构造题的更多相关文章
- 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) C. Vladik and fractions(构造题)
传送门 Description Vladik and Chloe decided to determine who of them is better at math. Vladik claimed ...
- 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 ...
随机推荐
- MVC过滤器
MVC的每一个请求都会给相应的控制器的对应行为方法处理,那么想在这些处理的前 前后后增加一些额外的逻辑处理,因此过滤器的作用就来了 MVC支持的过滤器类型有四种,分别是:Authorization(授 ...
- 准备找工作第三天——java基础_由有道云笔记倒入
循环:跳出多重循环:通过设置标号: 1 ok: 2 for(int i=0;i<10;i++) 3 { 4 for(int j=0;j<10;j++) 5 { ...
- Yaf零基础学习总结3-Hello Yaf
Yaf零基础学习总结3-Hello Yaf 上一次我们已经学习了如何安装yaf了,准备工作做好了之后我们来开始实际的编码了,码农都知道一个经典的语句就是“Hello World”了,今天我们开始入手Y ...
- hdu - 3959 Board Game Dice(数学)
这道题比赛中没做出来,赛后搞了好久才出来的,严重暴露的我薄弱的数学功底, 这道题要推公式的,,,有类似于1*a+2*a^2+3*a^3+...+n*a^n的数列求和. 最后画了一张纸才把最后的结果推出 ...
- Webpack使用教程六(Plugins)
webpack可以通过插件进行功能扩展.webpack拥有很多的内置插件和第三方插件.下面以webpack自带的插件bannerPlugin为例,说明插件的简单用法.bannerPlugin可以将任何 ...
- JAVA的初始化顺序(续)
JAVA在创建对象之前,是先加载类,然后再创建对象. 加载类时,会加载静态的成员变量,包括父类的静态成员变量[先加载父类,再加载子类]. 一. 静态成员变量的初始化 package com.cnbl ...
- orcale 匿名代码块
declare cursor readflow_cur is select * from od_readflow t where t.flowid is null; l_emp od_readflow ...
- [Xamarin] 使用LayoutInflater.Inflate載入預先設計好的Layout並使用 (转帖)
開發的時候,一定會把一些東西設計成元件,並且可以多次使用,今天紀錄一篇比較簡單的方法,可以載入事先做好的Layout 並且給予事件 介紹一下範例: Main.axml: <?xml versio ...
- 我使用中的Linux命令和快捷键(For Ubuntu)
虽然自己工作一直都在MS的平台体系,自然很多的工作都需要在windows上完成,自己的电脑也一直使用windows操作系统,但是笔记本配置不是很好,导致装windows 8后,笔记本卡的难以忍受.想想 ...
- ASP.NET前端解决方案之一:Ext.Net入门随笔1
最近因为公司需要,进一步研发了Ext.Net技术,这里先做一个简明的介绍,给自己和大家记录一个初步的概念. 什么是Ext Ext就是ExtJS,引用下百度的解释:“ExtJS是一种主要用于创建前端用户 ...