【44.64%】【codeforces 743C】Vladik and fractions
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
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.
Input
The single line contains single integer n (1 ≤ n ≤ 104).
Output
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.
Examples
input
3
output
2 7 42
input
7
output
7 8 56
【题目链接】:
【题解】
先让x=n
则转换成
1/n=1/y+1/z;
再做一下变化得到
z=n*y/(y-n)
可以看到
如果让y=n+1
那么z的分母为1
则z肯定是一个整数了
且x=n,y = n+1,z =n*(n+1)
当n大于1的时候x
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x)
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
//const int MAXN = x;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
LL n,a,b,c;
int main()
{
//freopen("F:\\rush.txt","r",stdin);
rel(n);
if (n==1)
{
puts("-1");
}
else
{
a = n,b = n+1,c = n*n+n;
cout << a << " " << b << " " <<c<<endl;
}
return 0;
}
相关文章
- A. The Fair Nut and Elevator (Codeforces Round #526 (Div. 2))
- A. Vova and Train ( Codeforces Round #515 (Div. 3) )
- ORA-24075: cannot specify agent with NULL address and non-NULL protocol ORACLE 报错 故障修复 远程处理
- ORA-27424: calendar clauses string and string are incompatible ORACLE 报错 故障修复 远程处理
- ORA-03288: both FREELIST GROUP and INSTANCE parameters may not be specified ORACLE 报错 故障修复 远程处理
- ORA-13291: conversion error between the specified unit and standard unit ORACLE 报错 故障修复 远程处理
- ORA-15246: cannot bring ASM disk string both online and then offline in the same statement ORACLE 报错 故障修复 远程处理
- FunDA(17)- 示范:异常处理与事后处理 – Exceptions handling and Finalizers详解编程语言
- What’s the difference between SHGetMalloc, SHAlloc, CoGetMalloc, and CoTaskMemAlloc详解编程语言
- neOracle Engine: Unleashing Power and Speed.(oracleeng)
- Exploring the Power of Linux’s Read and Write Functions: A Comprehensive Guide(linux读写函数)
- Exploring the Benefits and Uses of PPPD in the Linux Environment(pppdlinux)
- Maximizing performance and efficiency with Oracle EM services(oracleem服务)
- Oracle数据库中的AND查询(oracle and查询)
- Mysql中强大的AND运算符的使用方法探究(mysql中and的使用)
- MySQL中的AND和OR使用逻辑运算符优化查询语句(mysql中and与or)
- Oracle中使用除了And的其他查询关键字(oracle中除了and)
- php异常:Parseerror:syntaxerror,unexpectedT_ENCAPSED_AND_WHITESPACEeval()'dcodeerror