http://acm.hdu.edu.cn/showproblem.php?pid=6373 题目大概是说有一块板,求 球能在板上弹几次.
乍一看,好麻烦啊,然后做的时候你会发现,其实真的很麻烦.....
和做高中物理题一样
看成g分解为沿斜面和垂直鞋面的部分计算.高中物理就经常错在时间上,要记住你算的时间是一次的,弹起来在落下是两倍的时间!
#include <iostream>
#include <string>
#include <cstring>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <map>
#define sd(qwe) scanf("%d",&qwe)
#define se(cvb) scanf("%lf",&cvb)
#define ss(asd) scanf("%s",asd)
#define sc(xcv) scanf("%c",&xcv)
#define xh(ert,rty,tyu) for(int ert=rty;ert<=tyu;ert++)
#define fxh(u,i,o) for(int u=i;u>=o;u--)
using namespace std;
int main()
{int k;sd(k);
while(k--)
{double a,b,c,d,g=9.8;se(a);se(b);se(c);se(d);c=-c;
double ax=sin(atan(b/a))*g;
double y=(d-c*b/a);double yt=sqrt(2*y/g);
double x=c/cos(atan(b/a));
double vx=yt*ax;
int ans=1;
while(x>0)
{
x-=(vx*2*yt+ax*yt*yt*2);
if(x>0)ans++;
else
break;
vx=vx+2*ax*yt;
}
printf("%d\n",ans);
}
return 0;
}