codeforces #384 Vladik and fractions (构造算法)
来源:互联网 发布:java编程框架 编辑:程序博客网 时间:2024/05/17 22:39
Problem:
给定一个n,有三个不超过10^9的x,y,z,使得2/n = 1/x + 1/y + 1/z,后三个数是真分数。
Solution:
将已知数2/n进行分解,n/2 = 1/n + 1/(n+1) + 1/(n*(n+1));
#include<cstdio>#include<iostream>#include<sstream>#include<cstdlib>#include<cmath>#include<cctype>#include<string>#include<cstring>#include<algorithm>#include<stack>#include<queue>#include<set>#include<map>#include<ctime>#include<vector>#include<fstream>#include<list>using namespace std;#define ms(s) memset(s,0,sizeof(s))const double PI = 3.141592653589;const int INF = 0x3fffffff;int main(){ // freopen("/Users/really/Documents/code/input","r",stdin); // freopen("/Users/really/Documents/code/output","w",stdout); ios::sync_with_stdio(false); long long n; cin >> n; if(n == 1LL || n*(n+1) > 1000000000LL) cout << "-1" << endl; else{ cout << n << " " << (n+1) << " " << n*(n+1) << endl; } return 0;}
1 0
- codeforces #384 Vladik and fractions (构造算法)
- Codeforces 743C-Vladik and fractions(构造)
- codeforces 743-C. Vladik and fractions(构造)
- codeforces 743 C. Vladik and fractions(构造)
- CodeForces-743C Vladik and fractions(构造)
- Codeforces743C-Vladik and fractions(构造)
- codeforce 743 C. Vladik and fractions (数学构造)
- Codeforces Round #384(Div. 2)C. Vladik and fractions【数学】
- Codeforces Round #384 (Div. 2) C Vladik and fractions
- Codeforces Round #384 (Div. 2)-C. Vladik and fractions
- Codeforces Round #384 (Div. 2) C. Vladik and fractions
- Codeforces Round #384 (Div. 2) 743C Vladik and fractions
- Codeforces Round #384 (Div. 2) C. Vladik and fractions
- Codeforces 743C Vladik and fractions(数学)
- 【44.64%】【codeforces 743C】Vladik and fractions
- 743C. Vladik and fractions codeforces
- 【Codeforces 743C Vladik and fractions】
- codeforces 743 C. Vladik and fractions (数学)
- The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
- CCF模拟题-1~5
- Codeforces Round #384 (Div. 2) A. Vladik and flights【思维】水题
- Android笔记:通过代码设置系统壁纸
- 使用AES加密的时候(encryptString:(NSString*)string withKey:(NSString*)key) 出现结果是nil
- codeforces #384 Vladik and fractions (构造算法)
- apk重新签名
- 把ArrayList转化为json对象
- dubbo学习笔记 一 源码编译
- 初级音乐播放器——播放存储卡上的一首音乐,能够显示歌曲名和播放进度,并且能够播放和暂停(没有SD卡会报错)
- jenkins集成html report 不显示
- SPRD Android 6.0 安装美图美颜相机录像时,提示没有mic权限的问题。
- iOS 8 WkWebView 网页的配置和前进,后退,js 交互和进度条的加载
- Android:onNewIntent()触发机制及注意事项