HDU_4036 Rolling Hongshu

   物理题,我把公式推错了。。。

  两个限制条件,1、能爬上最高坡。2、Sweet Potato在每一个有Bitter Potatoes位置的速度大于等于Bitter 的速度。

设要求的初速度为pv

1、pv = sqrt(2*g*(maxh - h0));

2、pv = tpv = sqrt(vi*vi + 2*g*hi); 为bitter potato纵坐标。

View Code
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>

using namespace std;

const int MAX = 1010;
const double g = 20.0;

struct Mot {
double x;
double h;
} M[MAX];

int main() {
//freopen("data.in", "r", stdin);

int T, n, m, i, j, cas = 0;
double pv, tpv, x;
double mi, vi, w, hi;
scanf("%d", &T);
while(T--) {
scanf("%d%d%lf", &n, &m, &w);
pv = 0;
for(i = 0; i < n; ++i) {
scanf("%lf%lf", &M[i].x, &M[i].h);
if(M[i].h - M[0].h >= 0) {
tpv = sqrt(2*g*(M[i].h - M[0].h));
if(tpv > pv) pv = tpv;
}
}

for(i = 0; i < m; ++i) {
scanf("%lf%lf%lf", &x, &vi, &mi);
x += M[0].x;
for(j = 0; j < n; ++j) {
if(M[j].x <= x && M[j + 1].x >= x) {
hi = (M[j + 1].h - M[j].h)*(x - M[j].x)/(M[j + 1].x - M[j].x) + M[j].h;
hi -= M[0].h;
break;
}
}
tpv = sqrt(vi*vi + 2*g*hi);
if(tpv > pv) pv = tpv;
}
printf("Case %d: %.2lf\n", ++cas, pv);
}
return 0;
}



posted @ 2012-04-05 17:15  AC_Von  阅读(257)  评论(0编辑  收藏  举报