Fzu _ problem 2148 moon game

Source: Internet
Author: User
Problem 2148 moon gameAccept: 386 submit: 1080
Time Limit: 1000 msec memory limit: 32768 kb Problem 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-dimen=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 input2
4
0 0
100 0
0 100
100 100
4
0 0
100 0
0 100
10 10 sample outputcase 1: 1
Case 2: 0

Http://acm.fzu.edu.cn/problem.php? PID = 1, 2148

// The question is how many convex quadrants can be formed at most for a given point.

How to determine a convex quadrilateral: If a vertex D exists in the four points, sabd + SACD + SBCD = SABC, it indicates a concave quadrilateral. Because N is very small, it indicates whether each of the four vertices is a convex quadrilateral.


# Include <cstdio> # include <cmath> using namespace STD; const double EPS = 1e-8; struct point {int X, Y;} p [35]; double area (point, point B, point C) // Triangle Area Formula {return FABS (1.0 * (. x * B. Y + B. x * C. Y + C. x *. y-a.x * C. y-b.x *. y-c.x * B. y)/2;} bool check (point a, point B, point C, point D) // determines whether it is a convex edge. Note that assume a is an interior point of the Quadrilateral, to correspond to the following four repeated loops {If (FABS (area (B, c, d)-area (a, B, c)-area (a, B, d) -Area (A, C, D) <EPS) // return 0; return 1;} int main () {int T, I, j, k, n, a, B, ans; scanf ("% d", & T); For (k = 1; k <= T; k ++) {ans = 0; scanf ("% d", & N); for (I = 0; I <n; I ++) scanf ("% d", & P [I]. x, & P [I]. y); If (n <4) printf ("case % d: % d \ n", K, ANS); else {for (I = 0; I <N; I ++) for (j = I + 1; j <n; j ++) for (a = J + 1; A <n; A ++) for (B = a + 1; B <n; B ++) if (check (P [I], p [J], p [a], p [B]) & check (P [J], p [I], p [a], p [B]) & check (P [a], p [I], P [J], p [B]) & check (P [B], p [I], p [J], p [a]) ans ++; printf ("case % d: % d \ n", K, ANS) ;}} return 0;
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.