UVALive 4579 Time Lapse Camera

来源:互联网 发布:上海税友有哪些软件 编辑:程序博客网 时间:2024/05/16 14:56
UVALive -4579
Time Lapse Camera
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 (xy) betweenimages 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, 2550, 2535, 3015, 1712, 2316, 1115, 1225, 2035, 250

SampleOutput 

Test case 1: 30.00Test case 2: 23.25Test 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; }


0 0
原创粉丝点击