Positive Con Sequences
来源:互联网 发布:350淘宝装修平台 编辑:程序博客网 时间:2024/04/29 19:01
题意就是:4个等比或等差的数,缺了一个,你要求出那个数。
思路:对每个位置考虑下
#include"iostream"#include"cstdlib"#include"cmath"using namespace std;int main(){ long long a,b,c,d,t,x;while(cin>>a>>b>>c>>d,a!=-1||b!=-1||c!=-1||d!=-1){ if(a==-1) { x=c/b; t=b/x; if(t*x==b&&t*x*x==c&&t*x*x*x==d&&t>0&&t<=10000) cout<<t<<endl; else { x=c-b; t=b-x; if(t+x==b&&t+2*x==c&&t+3*x==d&&t>0&&t<=10000) cout<<t<<endl; else cout<<"-1"<<endl; } } if(b==-1) { x=d/c; t=c/x; if(t/x==a&&t*x==c&&t*x*x==d&&t>0&&t<=10000) cout<<t<<endl; else { x=d-c; t=c-x; if(t-x==a&&t+x==c&&t+2*x==d&&t>0&&t<=10000) cout<<t<<endl; else cout<<"-1"<<endl; } } if(c==-1) { x=b/a; t=d/x; if(t/x/x==a&&t/x==b&&t*x==d&&t>0&&t<=10000) cout<<t<<endl; else { x=b-a; t=b+x; if(t-2*x==a&&t-x==b&&t+x==d&&t>0&&t<=10000) cout<<t<<endl; else cout<<"-1"<<endl; } } if(d==-1) { x=c/b; t=c*x; if(t/x/x/x==a&&t/x/x==b&&t/x==c&&t>0&&t<=10000) cout<<t<<endl; else { x=c-b; t=c+x; if(t-3*x==a&&t-2*x==b&&t-x==c&&t>0&&t<=10000) cout<<t<<endl; else cout<<"-1"<<endl; } }} return 0;}
0 1
- Positive Con Sequences
- csuoj-1715-Positive Con Sequences
- CSU 1715 Positive Con Sequences
- CSU-1715 Positive Con Sequences(模拟分四种情况 )From湖南省多校对抗赛E题(2016.03.27)
- con
- sequences
- Sequences
- Con Kolivas
- “con”未定义
- sqlconnection con.close和con.dispose区别
- xorg.con 设置
- Pro and con
- ATL and CON
- VSTO Performance (Con'd)
- fopen("con","w")
- English_study Con(m)
- 华为con口密码
- PHP Con 2017 见闻
- 初识C++之继承
- 重视!!!Tomcat 严重: Catalina.stop 问题解决
- 0036vs2008下ogre1.6.5常见的一个配置小遗漏
- NOIP普及组2013 计数问题
- 验证码功能实现
- Positive Con Sequences
- 微信公众号的开发之旅(1)
- TableView性能优化
- 孩子们的游戏(圆圈中最后剩下的数)
- Servlet开发过程中乱码问题解决
- CodeForce 628B New Skateboard 水题
- apache2.4.12 局域网的其他电脑,无法访问我的apache
- 对各种排序的分析和实现
- shell 之 tar