比赛 | 普及组水题赛(语言题赛) | 评测结果 | EEEEE |
---|---|---|---|
题目名称 | 一元三次方程求解 | 最终得分 | 0 |
用户昵称 | 席一鸣 | 运行时间 | 0.604 s |
代码语言 | C++ | 内存使用 | 0.31 MiB |
提交时间 | 2014-10-14 19:28:46 | ||
- #include<cstdio>
- #include<iostream>
- using namespace std;
- int main()
- {
- freopen("3cfc","r",stdin);
- freopen("3cfc","w",stdout);
- double a,b,c,d,ans[3],t;
- int x=0;
- cin>>a>>b>>c>>d;
- for (int i=-10000;i<=10000;i++)
- {
- t=i/100.0;
- if ((t*t*t*a+t*t*b+t*c+d>-0.0001)&&(t*t*t*a+t*t*b+t*c+d<0.0001))
- {
- ans[x]=t;
- x++;
- }
- }
- for (int i=0;i<3;i++)
- {
- printf("%0.2f",ans[i]);
- cout<<' ';
- }
- }