• FZU 2148 Moon Game


    Moon Game
    Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

    Description

    Fat brother and Maze are playing a kind of special (hentai) game in the clearly blue sky which we can just consider as a kind of two-dimensional plane. Then Fat brother starts to draw N starts in the sky which we can just consider each as a point. After he draws these stars, he starts to sing the famous song “The Moon Represents My Heart” to Maze.

    You ask me how deeply I love you,

    How much I love you?

    My heart is true,

    My love is true,

    The moon represents my heart.

    But as Fat brother is a little bit stay-adorable(呆萌), he just consider that the moon is a special kind of convex quadrilateral and starts to count the number of different convex quadrilateral in the sky. As this number is quiet large, he asks for your help.

    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 contains an integer N describe the number of the points.

    Then N lines follow, Each line contains two integers describe the coordinate of the point, you can assume that no two points lie in a same coordinate and no three points lie in a same line. The coordinate of the point is in the range[-10086,10086].

    1 <= T <=100, 1 <= N <= 30

    Output

    For each case, output the case number first, and then output the number of different convex quadrilateral in the sky. Two convex quadrilaterals are considered different if they lie in the different position in the sky.

    Sample Input

    2 4 0 0 100 0 0 100 100 100 4 0 0 100 0 0 100 10 10

    Sample Output

    Case 1: 1 Case 2: 0
     1 #include <stdio.h>
     2 #include <string.h>
     3 #include <math.h>
     4 #include <algorithm>
     5 using namespace std;
     6 
     7 int T;
     8 int n,ca=1;
     9 int i,j,k,l;
    10 double x[35],y[35];
    11 
    12 double S(double x1,double y1,double x2,double y2,double x3,double y3)
    13 {
    14     double K=(x1*y2+x2*y3+x3*y1-x1*y3-x2*y1-x3*y2)/2.0;
    15     return fabs(K);
    16 }
    17 
    18 int check()
    19 {
    20     double S123,S124,S134,S234;
    21     S123=S(x[i],y[i],x[j],y[j],x[k],y[k]);
    22     S124=S(x[i],y[i],x[j],y[j],x[l],y[l]);
    23     S134=S(x[i],y[i],x[k],y[k],x[l],y[l]);
    24     S234=S(x[j],y[j],x[k],y[k],x[l],y[l]);
    25     //printf("%lf %lf %lf %lf
    ",S123,S124,S134,S234);
    26     if(fabs(S124+S134+S234-S123)==0)
    27         return 0;
    28     if(fabs(S124+S134-S234+S123)==0)
    29         return 0;
    30     if(fabs(S124-S134+S234+S123)==0)
    31         return 0;
    32     if(fabs(S134+S234+S123-S124)==0)
    33         return 0;
    34     return 1;
    35 }
    36 
    37 int main()
    38 {
    39     scanf("%d",&T);
    40     while(T--)
    41     {
    42         int num=0;
    43         scanf("%d",&n);
    44         for(i=1;i<=n;i++)
    45             scanf("%lf %lf",&x[i],&y[i]);
    46         for(i=1;i<=n-3;i++)
    47         {
    48             for(j=i+1;j<=n-2;j++)
    49             {
    50                 for(k=j+1;k<=n-1;k++)
    51                 {
    52                     for(l=k+1;l<=n;l++)
    53                     {
    54                         //printf("%d %d %d %d
    ",i,j,k,l);
    55                         if(check()==1)
    56                             num++;
    57                     }
    58                 }
    59             }
    60         }
    61 
    62         printf("Case %d: %d
    ",ca++,num);
    63     }
    64     return 0;
    65 }
    View Code
  • 相关阅读:
    Ubuntu 11.10 安装JDK
    virtualbox下安装ubuntu
    GridView控件的DataKeyNames
    Asp.net中防止用户多次登录的方法
    在asp.net中使用线程
    SQL2008更改表结构问题
    Ubuntu安装run文件
    ContextSwitchDeadlock
    CheckedListBox用法
    C#图片加水印图片和文字
  • 原文地址:https://www.cnblogs.com/cyd308/p/4771418.html
Copyright © 2020-2023  润新知