zoukankan      html  css  js  c++  java
  • Problem 2144 Shooting Game fzu

    Problem 2144 Shooting Game

    Accept: 99    Submit: 465
    Time Limit: 1000 mSec    Memory Limit : 32768 KB

     Problem Description

    Fat brother and Maze are playing a kind of special (hentai) game in the playground. (Maybe it’s the OOXX game which decrypted in the last problem, who knows.) But as they don’t like using repellent while playing this kind of special (hentai) game, they really suffer a lot from the mosquito. So they decide to use antiaircraft gun to shoot the mosquito. You can assume that the playground is a kind of three-dimensional space and there are N mosquitoes in the playground. Each of them is a kind of point in the space which is doing the uniform linear motion. (匀速直线运动) Fat brother is standing at (0, 0, 0) and once he shoot, the mosquito who’s distance from Fat brother is no large than R will be shot down. You can assume that the area which Fat brother shoot is a kind of a sphere with radio R and the mosquito inside this sphere will be shot down. As Fat brother hate these mosquito very much, he wants to shoot as much mosquito as he can. But as we all know, it’s tired for a man to shoot even if he is really enjoying this. So in addition to that, Fat brother wants to shoot as less time as he can.

    You can (have to) assume that Fat brother is strong enough and he don’t need to rest after shooting which means that can shoot at ANY TIME.

     Input

    The first line of the date is an integer T, which is the number of the text cases.

    Then T cases follow, each case starts with two integers N and R which describe above.

    Then N lines follow, the ith line contains six integers ax, ay, az, dx, dy, dz. It means that at time 0, the ith mosquito is at (ax, ay, az) and it’s moving direction is (dx, dy, dz) which means that after time t this mosquito will be at (ax+dx*t, ay+dy*t, ax+dz*t). You can assume that dx*dx + dy*dy+ dz*dz > 0.

    1 <= T <= 50, 1 <= N <= 100000, 1 <= R <= 1000000

    -1000000 <= ax, ay, az <= 1000000

    -100 <= dx, dy, dz <= 100

    The range of each coordinate is [-10086, 10086]

     Output

    For each case, output the case number first, then output two numbers A and B.

    A is the number of mosquito Fat brother can shoot down.

    B is the number of times Fat brother need to shoot.

     Sample Input

    6
    2 1
    2 0 0 -1 0 0
    -2 0 0 1 0 0
    2 1
    4 0 0 -1 0 0
    -2 0 0 1 0 0
    2 1
    4 0 0 -1 0 0
    1 0 0 1 0 0
    2 1
    1 1 1 1 1 1
    -1 -1 -1 -1 -1 -1
    1 1
    0 0 0 1 0 0
    3 1
    -1 0 0 1 0 0
    -2 0 0 1 0 0
    4 0 0 -1 0 0

     Sample Output

    Case 1: 2 1
    Case 2: 2 1
    Case 3: 2 2
    Case 4: 0 0
    Case 5: 1 1
    Case 6: 3 2
     
     
    卡精度和输入要用long long,用int会爆
     1 #include <iostream>
     2 #include <string.h>
     3 #include <stdio.h>
     4 #include <math.h>
     5 #include <vector>
     6 #include <algorithm>
     7 #include <cmath>
     8 #include <cstdio>
     9 #include <cctype>
    10 #include <iostream>
    11 #define eps 1e-8
    12 using namespace std;
    13 typedef struct abcd
    14 {
    15     double t1,t2;
    16 } tii;
    17 double Abs(double x){return x>0?x:-x;}
    18 int n,nu;
    19 long long r;
    20 tii ti[101000];
    21 long long a[101000][6];
    22 bool cmp(tii x,tii y)
    23 {
    24     return x.t2<y.t2;
    25 }
    26 void fun(int k)
    27 {
    28     double aa=a[k][3]*a[k][3]+a[k][4]*a[k][4]+a[k][5]*a[k][5];
    29     double b=2*(a[k][0]*a[k][3]+a[k][1]*a[k][4]+a[k][2]*a[k][5]);
    30     double c=a[k][0]*a[k][0]+a[k][1]*a[k][1]+a[k][2]*a[k][2]-r*r;
    31     double d=b*b-4*aa*c;
    32     if(Abs(d)<eps)return ;
    33     else
    34     {
    35         ti[nu].t1=(-b-sqrt(d))/(2*aa);
    36         ti[nu].t2=(-b+sqrt(d))/(2*aa);
    37         if(ti[nu].t1>ti[nu].t2)swap(ti[nu].t1,ti[nu].t2);
    38         if(ti[nu].t1>=0||ti[nu].t2>=0)
    39         {
    40             if(ti[nu-1].t1<0)ti[nu-1].t1=0;
    41             nu++;
    42         }
    43     }
    44 }
    45 int main()
    46 {
    47     //freopen("in.txt","r",stdin);
    48     int t,i,j;
    49     scanf("%d",&t);
    50     for(i=1; i<=t; i++)
    51     {
    52         nu=0;
    53         scanf("%d%I64d",&n,&r);
    54         for(j=0; j<n; j++)
    55         {
    56             scanf("%I64d%I64d%I64d%I64d%I64d%I64d",&a[j][0],&a[j][1],&a[j][2],&a[j][3],&a[j][4],&a[j][5]);
    57             fun(j);
    58         }
    59         sort(ti,ti+nu,cmp);
    60         int ci=0;
    61         double now;
    62         for (j=0;j<nu;)
    63         {
    64             now=ti[j].t2;
    65             ci++;
    66             j++;
    67             while(j<nu&&ti[j].t1<=now)j++;
    68         }
    69         printf("Case %d: %d %d
    ",i,nu,ci);
    70     }
    71 }
    View Code
     
  • 相关阅读:
    Pausing Coyote HTTP/1.1 on http-8080
    网站后台管理中生成首页失败
    Eclipse快捷键集结
    电子商务网站推广10大方法
    Eclipse使用
    注册表中更换桌面背景
    网站卡死,照惯例运行.bat批量处理文件进行重启不起作用
    同时处理html+js+jquery+css的插件安装(Spket&Aptana插件安装)
    JQuery的插件
    Eclipse插件
  • 原文地址:https://www.cnblogs.com/ERKE/p/3635542.html
Copyright © 2011-2022 走看看