现在的位置: 首页 > 综合 > 正文

Timus 1800

2012年11月19日 ⁄ 综合 ⁄ 共 408字 ⁄ 字号 评论关闭
#include <iostream>
#include
<math.h>
using namespace std;

int main() {

double l,w,h,t,g=981,r,rs,rm;
cin
>>l>>h>>w;

if(h <= l/2) {
cout
<<"butter"<<endl;
return 0;
}

//求出来的t可能是无效数字,所以要防止2*h-l是负数

t
= pow((2*h-l)/g, 0.5);
r
= 60 / w;
rs
= t / r;
rm
= rs - (int)rs;
if(rm < 0.25f || rm > 0.75f)
cout
<<"butter"<<endl;
else
cout
<<"bread"<<endl;

return 0;
}

记得呆牛以前问过我一条方程能不能解,就是用来解这题,不过看来他当时一开始想错思路了,不过以他的智慧马上就应该意识到不需要解那方程。

这题让我纠结了很久,竟然忘记题目给的参数是厘米。。哎。。23岁的生日就这样被这题坑了。 T_T

抱歉!评论已关闭.