UVALive 4579 Time Lapse Camera

UVALive -4579
Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld &%llu

[Submit [GoBack  [Status 

Description

Download as PDF

Henry has a time lapse camera that can take a set of 3 images inone shot. The three images are taken by the camera at differenttime lapse. For example, if the first image is taken at 0.33seconds after the shot, then the second image is automaticallytaken at 0.51 seconds and the third image is taken at 0.62 secondsafter the shot. The time lapses of taking the images are notreliable but the spatialcoordinate (xybetweenimages remain the same due to high speed shutter.

One nice evening during a sport festival, Henry placed a gridnet in front of camera and started shooting the movement of a ball.Once the images were developed, Henry measured and recorded thecoordinates of the ball on each image. Now he wants to know thehighest height that the ball had achieved in a set of 3 images.

You need to help Henry by writing a program to compute theapproximation of height that the ball has achieved in each set ofimages by assuming that the movement of the ball forms a paraboliccurve.

Input 

A test case consists of the coordinate of 3 points where theball was captured by the camera. Input consists of several testcases. Each coordinate will not exceed 500.0 in absolute value. Theinput is terminated by a zero on a line by itself.

Output 

Approximation of highest height that the ball has achieved ineach test case

SampleInput 

20, 25
50, 25
35, 30
15, 17
12, 23
16, 11
15, 12
25, 20
35, 25
0

SampleOutput 

Test case 1: 30.00
Test case 2: 23.25
Test case 3: 27.04
 
       
 
       
#include<stdio.h>
int main() 
{ 
 
       
 
       
  char p; 
 int k=1; 
        double a,b,c,x1,x2,x3,y1,y2,y3; 
      while(~scanf("%lf",&x1)) 
{ 
            if(!x1)
                        break; 
                else 
                      scanf("%c%lf",&p,&y1); 
                 scanf("%lf, %lf",&x2,&y2); 
                           scanf("%lf, %lf",&x3,&y3); 
                 b=y2-y3-(y1-y2)*(x2*x2-x3*x3)/(x1*x1-x2*x2); 
                  b/=(x2-x3-(x2*x2-x3*x3)/(x1+x2)); 
                 a=(y1-y2-b*(x1-x2))/(x1*x1-x2*x2); 
                 c=y1-a*x1*x1-b*x1; 
    printf("Test case %d: %.2lf\n",k++,c-b*b/4/a); 
} 
return 0; }
 
       


 
       
 
       
 
       
 
       
 
       
 
       
 
       
 
       
 
       
 
       
 
      


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值