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. python2读取EXCEL表格内的数据时碰到的问题

    一,今天在剥离自动化的测试数据时,发生了一个错误,错误显示读取不到某个单元格的数据. 因为我使用的是python2,正好那一个单元格出现的是中文汉字,再者通过查看报错日志,让我了解到错误的原因. di ...

  2. JavaBean详解

    JavaBean详解 我们对JavaBean的理解可以从java和bean两个方面来理解,对于Java我们都很清楚,而bean在计算机中的含义为可重用组件.(ps:对Spring中的bean是不是有了 ...

  3. js基本函数和基本方法

    日期时间函数(需要用变量调用): var b = new Date(); //获取当前时间 b.getTime() //获取时间戳 b.getFullYear() //获取年份 b.getMonth( ...

  4. 第一周复习二 (CSS样式表及其属性)

    样式表三种写法 1内联写法:style直接写在标签内.个人感觉多用于个别标签,一般情况优先级较高 style="font-size:16px;" 2内嵌写法:写在<head& ...

  5. [已解决]报错: twisted 18.7.0 requires PyHamcrest>=1.9.0

    1.下载对应的Twisted,下载地址:https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted 2.通过Anaconda3的Anaconda Promp ...

  6. Pyhon 格式化输出的几种方式

    废话不多说,直接上代码 第一种格式化的输出方式,拼接我就不上了,不建议使用,数据多的时候自己都蒙圈 # -*- coding:utf-8 -*- # Author:覃振鸿 #格式化输出 name=in ...

  7. Codesforces 485D Maximum Value

                                                      D. Maximum Value   You are given a sequence a cons ...

  8. linux CentOS7 安装 Java

    1. http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html先去下载 java 对应的 ...

  9. 事件循环--eventloop

    一.什么是事件循环? 事件循环是 JS 实现异步的具体解决方案,同步代码直接执行,异步函数或代码块先放在异步队列中,待同步函数执行完毕,轮询执行异步队列的函数. 事件循环 二.node.js中的事件循 ...

  10. 2018-2-13-win10-uwp-hashcash

    title author date CreateTime categories win10 uwp hashcash lindexi 2018-2-13 17:23:3 +0800 2018-2-13 ...