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. php环境搭建以及优化

    WampServer 配置伪静态 httpd.conf文件 搜索找到“LoadModule rewrite_module modules/mod_rewrite.so”这一行,去掉前面的“#”: 搜索 ...

  2. PAT 1042 Shuffling Machine (20 分)

    1042 Shuffling Machine (20 分)   Shuffling is a procedure used to randomize a deck of playing cards. ...

  3. JS-ValidForm:介绍

    ylbtech-JS-ValidForm:介绍 1.返回顶部 1. 关于Validform Validform:一行代码搞定整站的表单验证! 1 $(".demoform").Va ...

  4. flask-sqlalchemy报错 Object '<User at xxxx>' is already attached to session '1' (this is '2')

    报错:  Object '<User at xxxx>' is already attached to session '1' (this is '2') 结论:      两个不同的db ...

  5. switch gnome-terminal tabs

    Ctrl+Page Down (forward) and Ctrl+Page Up (backward). http://unix.stackexchange.com/a/67963

  6. Netty教程

    Netty是一个java开源框架.Netty提供异步的.事件驱动的网络应用程序框架和工具,用以快速开发高性能.高可靠性的网络服务器和客户端程序. Netty是一个NIO客户端.服务端框架.允许快速简单 ...

  7. 如何将英文版的Firefox添加中文版语言包

    http://ftp.mozilla.org/pub/firefox/releases/ xpi中下载zh_CN.xpi 文件 , 把文件拖拽进火狐浏览器 在地址栏输入”about:config”,回 ...

  8. 在apache hadoop2.6 上部署hive 并将hive数据源存储于Mysql

    集成hive 的前提是apache hadoop 集群能够正常启动. hadoop 版本 apach2.6.0  hive 版本:1.2.1 1.安装mysql 并赋予权限: 1.1:创建hive 用 ...

  9. 下载文件时HttpServletResponse设置响应头的Content-Disposition属性

    Content-Disposition属性有两种类型 inline :将文件内容直接显示在页面 attachment:弹出对话框让用户下载 弹出对话框下载文件 resp.setHeader(" ...

  10. ubuntu 设置root密码