#include<stdio.h>
#include<math.h>
#define N 1100
#define g 20
struct mountain
{
double x,high;
}mountains[N];
struct potato
{
double x,v,weight;
double high;
}potatos[N];
int main()
{
int t,n,m,casea=1;
double w;
scanf("%d",&t);
while(t--)
{
scanf("%d %d %lf",&n,&m,&w);
double initv=0.0,temp;
for(int i=1;i<=n;i++)
{
scanf("%lf%lf",&mountains[i].x,&mountains[i].high);
if(mountains[i].high<=mountains[1].high)
temp=0;
else
temp=sqrt(1.0*2*g*(mountains[i].high-mountains[1].high));
if(temp>initv)
initv=temp;
}
for(i=1;i<=m;i++)
{
scanf("%lf%lf%lf",&potatos[i].x,&potatos[i].v,&potatos[i].weight);
for(int j=1;j<n;j++)
{
if(potatos[i].x>=mountains[j].x && potatos[i].x<=mountains[j+1].x)
{
potatos[i].high=((potatos[i].x-mountains[j].x)*(mountains[j+1].high-mountains[j].high)/(mountains[j+1].x-mountains[j].x))+mountains[j].high;
break;
}
}
}
for(i=1;i<=m;i++)
{
temp=sqrt(1.0*potatos[i].v*potatos[i].v + 1.0*2*g*(potatos[i].high-mountains[1].high));
if(initv<temp)
initv=temp;
}
printf("Case %d: %.2lf\n",casea++,initv);
}
return 0;
}杭电 4036
最新推荐文章于 2021-02-22 14:35:11 发布
本文探讨了在复杂地形中,如何计算土豆在不同山峰间的滚动速度,以求达到最大速度。通过输入山峰数量、山峰高度、土豆位置、速度和重量等参数,算法计算出土豆在各段路径上的滚动高度,并最终确定整个路径中土豆能达到的最大滚动速度。
313

被折叠的 条评论
为什么被折叠?



