POJ 3684 Physics Experiment
和蚂蚁问题类似。
#include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<queue> #include<algorithm> using namespace std; int c,n; double h,r,t,T; double ans[105]; double cal(double time) { if(time<=0) return h; int f=0; while(1) { if(time<=T) { if(f==0) return h-0.5*10.0*time*time; return h-0.5*10.0*(T-time)*(T-time); } f=f^1; time=time-T; } } int main() { scanf("%d",&c); while(c--) { scanf("%d%lf%lf%lf",&n,&h,&r,&t); T=sqrt(2*h/10.0); for(int i=0;i<n;i++) ans[i]=cal(1.0*t-1.0*i); sort(ans,ans+n); for(int i=0;i<n;i++) ans[i]=ans[i]+2.0*r*i/100; for(int i=0;i<n;i++) { printf("%.2lf",ans[i]); if(i<n-1) printf(" "); else printf("\n"); } } return 0; }