2015
04-14

# Easy Fruit Ninja

YY is a clever boy . Recently he bought a new mobile phone .he is addicted in a game named Fruit Ninja . In the game . The fruit will fly from the bottom of the screen in a parabolic curve(g = 10.0 m/s^2). Your aim is cutting the fruit before the fruit fall down and disappear but you can’t cut it at time 0.0 . And YY is a lazy boy. He just want to cut the fruit use the least times . Every time he cut .all the fruit in the same line will be cut. To simple this problem .we regard the fruit as a point . The mobile phone is a Two dimensional coordinate department There are only three Fruit fly into the air. YY want to know if exist a time that three fruit are in a same line and what the time it is.

In the first line . Only a number T (1 <= T <= 1000) indicate the test case

each test case the first line contain three real number x1, x2, x3, indicate the coordinate of the fruit (x1, 0) (x2, 0), (x3, 0) ( – 10000 <= x1, x2, x3 <= 10000)

the second line contain three real number v1, v2, v3, indicate the speed of the fruit (0 <= v1, v2, v3 <= 10000)

the third line contain three real number a, b, c, indicate the radian of the fruit’s direction to the x coordinate ( 0 <= a, b, c <= pi )

In the first line . Only a number T (1 <= T <= 1000) indicate the test case

each test case the first line contain three real number x1, x2, x3, indicate the coordinate of the fruit (x1, 0) (x2, 0), (x3, 0) ( – 10000 <= x1, x2, x3 <= 10000)

the second line contain three real number v1, v2, v3, indicate the speed of the fruit (0 <= v1, v2, v3 <= 10000)

the third line contain three real number a, b, c, indicate the radian of the fruit’s direction to the x coordinate ( 0 <= a, b, c <= pi )

3
150 35 250
80 200 220
2.00 2.17 2.27

0 1 2
1 1 1
1 1 1

0 0 0
1 2 3
1 1 1

Case #1: 8.4151
Case #3: Multiply answer

#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define EPS 1e-8
int main(){
int t,i,ca=1;
scanf("%d",&t);
double ti,g=10;
double x0[3],vx[3],vy[3],d[3],v[3];
double a,b,t1,c;
while(t--){
for(i=0;i<3;i++)scanf("%lf",x0+i);
for(i=0;i<3;i++)scanf("%lf",v+i);
for(i=0;i<3;i++)scanf("%lf",d+i);
for(i=0;i<3;i++){
vx[i]=v[i]*cos(d[i]);
vy[i]=v[i]*sin(d[i]);
if(i==0 || ti>2*vy[i]/g)
ti=2*vy[i]/g;
}
a=(vx[0]-vx[1])*(vy[1]-vy[2])-((vx[1]-vx[2])*(vy[0]-vy[1]));
b=(x0[0]-x0[1])*(vy[1]-vy[2])-(x0[1]-x0[2])*(vy[0]-vy[1]);
printf("Case #%d: ",ca++);
if(ti<EPS)
printf("-1\n");
else if(fabs(a)<EPS && fabs(b)<EPS)
else if(fabs(a)<EPS)
printf("-1\n");
else{
t1=-b/a;
if(t1>EPS && ti-t1>-EPS )
printf("%.4lf\n",t1+EPS);
else
printf("-1\n");
}
}
return 0;
}

1. 我还有个问题想请教一下，就是感觉对于新手来说，递归理解起来有些困难，不知有没有什么好的方法或者什么好的建议？

2. [email protected]

3. #include <stdio.h>
int main(void)
{
int arr[] = {10,20,30,40,50,60};
int *p=arr;
printf("%d,%d,",*p++,*++p);
printf("%d,%d,%d",*p,*p++,*++p);
return 0;
}

为什么是 20,20,50,40,50. 我觉得的应该是 20,20,40,40,50 . 谁能解释下？