Codeforces Round #384 (Div. 2)

题目链接:Vladik and fractions

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 \(\frac{2}{n}\) as a sum of three distinct positive fractions in form \(\frac{1}{m}\).

Help Vladik with that, i.e for a given \(n\) find three distinct positive integers \(x, y\) and \(z\) such that \(\frac{2}{n} = \frac{1}{x} + \frac{1}{y} + \frac{1}{z}\). Because Chloe can't check Vladik's answer if the numbers are large, he asks you to print numbers not exceeding $10^9$.

If there is no such answer, print \(-1\).

Input

The single line contains single integer \(n (1 \le  n \le  10^4)\).

Output

If the answer exists, print 3 distinct numbers \(x, y\) and \(z (1 \le  x, y, z \le  10^9, x \neq y, x \neq  z, y \neq  z)\). Otherwise print \(-1\).

If there are multiple answers, print any of them.

Examples

input

3

output

2 7 42

input

7

output

7 8 56

Solution

题意

给定一个正整数 \(n\),求正整数 \(x,y,z\) 满足 \(\frac{2}{n} = \frac{1}{x} + \frac{1}{y} + \frac{1}{z}\)。

其中 \(x \neq y,\ x \neq z,\ y \neq z\)。若无解输出 \(-1\)。

题解

构造

\(\frac{1}{n} - \frac{1}{n + 1} = \frac{1}{n(n+1)}\)

\(\frac{1}{n} = \frac{1}{n + 1} + \frac{1}{n(n+1)}\)

\(\frac{2}{n} = \frac{1}{n + 1} + \frac{1}{n(n+1)} + \frac{1}{n}\)

当 \(n=1\) 时,\(\frac{2}{n}=2\)。而 \((\frac{1}{x}+\frac{1}{y}+\frac{1}{z})_{max} = \frac{1}{1}+\frac{1}{2}+\frac{1}{3} < 2\),所以当 \(n=1\) 时无解。

Code

#include <bits/stdc++.h>
using namespace std; int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
if(n == 1) cout << -1 << endl;
else cout << (n + 1) << " " << (n * (n + 1)) << " " << n << endl;
return 0;
}

Codeforces 743C - Vladik and fractions (构造)的更多相关文章

  1. CodeForces 743C Vladik and fractions (数论)

    题意:给定n,求三个不同的数满足,2/n = 1/x + 1/y + 1/z. 析:首先1是没有解的,然后其他解都可以这样来表示 1/n, 1/(n+1), 1/(n*(n+1)),这三个解. 代码如 ...

  2. Codeforces Round #384 (Div. 2) C. Vladik and fractions 构造题

    C. Vladik and fractions 题目链接 http://codeforces.com/contest/743/problem/C 题面 Vladik and Chloe decided ...

  3. CF C. Vladik and fractions——构造题

    题目 构造一组 $x, y, z$,使得对于给定的 $n$,满足 $\frac{1}{x}  + \frac{1}{y} + \frac{1}{z} =  \frac{2}{n}$. 分析: 样例二已 ...

  4. codeforces 811E Vladik and Entertaining Flags(线段树+并查集)

    codeforces 811E Vladik and Entertaining Flags 题面 \(n*m(1<=n<=10, 1<=m<=1e5)\)的棋盘,每个格子有一个 ...

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

  6. 【44.64%】【codeforces 743C】Vladik and fractions

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  7. Educational Codeforces Round 10 B. z-sort 构造

    B. z-sort 题目连接: http://www.codeforces.com/contest/652/problem/B Description A student of z-school fo ...

  8. Codeforces 707C Pythagorean Triples(构造三条边都为整数的直角三角形)

    题目链接:http://codeforces.com/contest/707/problem/C 题目大意:给你一条边,问你能否构造一个包含这条边的直角三角形且该直角三角形三条边都为整数,能则输出另外 ...

  9. Codeforces 1246D/1225F Tree Factory (构造)

    题目链接 https://codeforces.com/contest/1246/problem/D 题解 首先考虑答案的下界是\(n-1-dep\) (\(dep\)为树的深度,即任何点到根的最大边 ...

随机推荐

  1. CPU、内存、磁盘三者的关系

    参考:https://blog.csdn.net/weini1111/article/details/70849332 cpu是大脑,计算数据用的. 内存是草稿纸,开着电脑一直都在用里边的数据,如果断 ...

  2. 52、saleforce 导入csv文件

    Load Data Using the Custom Object Import Wizard 1. 2. 3. 4. 5. 6.然后就导入成功了

  3. 仅当使用了列列表并且 IDENTITY_INSERT 为 ON 时,才能为表'XXX'中的标识列指定显式值。

    (来自:https://zhidao.baidu.com/question/494717175.html)第一条回复,原因和例子都有了,解释的很好. 插入数据时,自增长列是系统自动处理,不需要你来指定 ...

  4. z-index只能用在定位元素上

    弄了很久才突然想到z-index只能用在被定位的元素上. 定位的时候要注意给父级定位 在ie7里有问题的部分

  5. 02 java语言基础

    常量:字面值常量(字符串,字符,整数,小数,布尔,null),自定义常量,''这个不是字符常量,""这个是字符串常量 进制: 02.01_Java语言基础(常量的概述和使用) A: ...

  6. HDU 1847 Good Luck in CET-4 Everybody! (巴什博弈)

    题目链接:HDU 1847 Problem Description 大学英语四级考试就要来临了,你是不是在紧张的复习?也许紧张得连短学期的ACM都没工夫练习了,反正我知道的Kiki和Cici都是如此. ...

  7. POJ 3641 Pseudoprime numbers (数论+快速幂)

    题目链接:POJ 3641 Description Fermat's theorem states that for any prime number p and for any integer a ...

  8. CSS Sprites技术原理和使用

      在分析各个网站的CSS时,我们经常可以看到一些网站有很多的元素共享了一张背景图片,而这张背景图片包含了所有这些元素需要的背景,这种技术就叫做CSS Sprites. 淘宝的css sprites ...

  9. 微信小程序 获取用户信息并保存登录状态

    微信小程序 获取用户信息并保存登录状态:http://www.360doc.com/content/18/0124/11/9200790_724662071.shtml

  10. bootstrap学习(三)表单

    基本实例: from-group:可以是其内的标签排列更好 from-control:使标签宽度为100% <form> <div class="form-group&qu ...