Codeforces Round #384 (Div. 2) 743C Vladik and fractions
来源:互联网 发布:保卫萝卜3修改炮塔数据 编辑:程序博客网 时间:2024/05/17 23:24
题意:给你个n,请你找出符合条件的x,y,z.
这题有比较巧妙的方法。
我们先令x,y,z中任意一个数为n ,这里我们让z=n 那么这个式子可以化简成:1/n=1/x+1/y
解一下这个式子:就能解除:y=(x*n)/(x-n)
如果要让y为整数的话。可以使这个式子的分母为1
那么x=N+1
则y=n*(n+1)
当n为1的时候,x,y,z不存在,输出-1
#include<bits/stdc++.h>using namespace std;int main(){ int n; while(~scanf("%d",&n)) { if(n==1) { printf("-1\n"); continue; } printf("%d %d %d\n",n+1,n*(n+1),n); } return 0;}
阅读全文
0 0
- Codeforces Round #384 (Div. 2) 743C 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) C. Vladik and fractions
- 【44.64%】【codeforces 743C】Vladik and fractions
- codeforces 743 C. Vladik and fractions(构造)
- 743C. Vladik and fractions codeforces
- CodeForces-743C Vladik and fractions(构造)
- 【Codeforces 743C Vladik and fractions】
- codeforces 743 C. Vladik and fractions (数学)
- Codeforces Round #384 (Div. 2) 743A Vladik and flights
- Codeforces Round #390 (Div. 2)C Vladik and chat
- Codeforces Round #416 (Div. 2)C. Vladik and Memorable Trip
- Codeforces Round #416 (Div. 2)-C. Vladik and Memorable Trip
- Codeforces Round #416 (Div. 2) C Vladik and Memorable Trip
- Codeforces Round #384 (Div. 2) A Vladik and flights
- 一位资深程序员大牛给予Java初学者的学习路线建议
- angularJs中对于日期时间格式化
- c语言中,两个指针相减的意义
- 机器学习实战 笔记 debug kNN(二)
- H5开发:JS自动识别移动端和PC端,分配二级域名
- Codeforces Round #384 (Div. 2) 743C Vladik and fractions
- #753 – ManipulationDelta中Scale和Expansion属性的区别(Scale vs. Expansion in ManipulationDelta Events)
- RTP协议全解析(H264码流和PS流)
- RadioButton再次点击取消
- Linux下将其它格式文件转化为pdf文件
- STM8 选项字节的写入
- Samsung TextView 坑之旅
- 7.18
- fork()与写时拷贝~