C. Vladik and fractions

http://codeforces.com/problemset/problem/743/C
构造题
2/n=1/a+1/b+1/c
a=n
b=m
c=m*n
解得m=n+1
当n=1时是无解的

#include <bits/stdc++.h>
#define inf 2333333333333333
#define N 1000010
#define p(a) putchar(a)
#define For(i,a,b) for(long long i=a;i<=b;++i)

using namespace std;
long long n;
void in(long long &x){
    long long y=1;char c=getchar();x=0;
    while(c<'0'||c>'9'){if(c=='-')y=-1;c=getchar();}
    while(c<='9'&&c>='0'){ x=(x<<1)+(x<<3)+c-'0';c=getchar();}
    x*=y;
}
void o(long long x){
    if(x<0){p('-');x=-x;}
    if(x>9)o(x/10);
    p(x%10+'0');
}

signed main(){
    in(n);
    if(n!=1) cout<<n<<" "<<n+1<<" "<<n*(n+1)<<endl;
    else o(-1);
    return 0;
}

 

posted @ 2020-07-05 23:04  WeiAR  阅读(139)  评论(0编辑  收藏  举报