FZU-2148 Moon Game

Source: Internet
Author: User

Problem 2148 Moon Game accept:499 submit:1398
Time limit:1000 mSec Memory limit:32768 KB Problem Description

Fat brother and Maze is playing a kind of special (hentai) game in the clearly blue sky which we can just consider as a K IND 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 what 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 (Moe), he just consider that the moon are a special kind of convex quadrilat eral and starts to count the number of different convex quadrilateral in the sky. As this number was quiet large, he asks for your help.

 Input

The first line of the date is a 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 the describe of the the "The point", you can coordinate that no, the assume TS lie in a same coordinate and no three points lie on a same line. The coordinate of the point was 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. Convex quadrilaterals is considered different if they lie in the different position in the sky.

 Sample Input24
0 0
100 0
0 100
100 100
4
0 0
100 0
0 100
10 10 Sample Outputcase 1:1
Case 2:0


Given n points (not heavy, no three-point collinear), how many convex quadrilateral can be composed. The concave quadrilateral must have a point within the triangle of the other three points, assuming the D point, at this time sabc=sabd+sacd+sbcd. Because N is 30 maximum, you can enumerate all the different four points, as long as there are no inner points in four points to satisfy the above equation is convex quadrilateral.

#include <iostream> #include <string> #include <cmath>using namespace std;const double Exp = 10e-6; struct Point{int x;int y;}; Double area (Point A, point B, point C) {return fabs (1.0* ((b.x-a.x) * (C.Y-A.Y)-(B.Y-A.Y) * (c.x-a.x))/2.0;} BOOL Check (point A, point B, point C, point D) {if (Fabs (area (A, B, c)-area (A, B, D)-area (b, C, D)-area (A, C, D)) &lt ; EXP) return False;return true;} int main () {int casen;cin >> casen;for (int cas = 1; CAs <= casen; cas++) {point p[35];int n;int cnt = 0;cin &GT;&G T  n;for (int i = 0; i < n; i++) cin >> p[i].x >> p[i].y;for (int p1 = 0; p1 < n; p1++) for (int p2 = p1 + 1; P2 < n; p2++) for (int p3 = p2 + 1; P3 < n; p3++) for (int p4 = p3 + 1; P4 < n; p4++) {if (check (P[P1], P[P2], p[p3], P[P4]) &A mp;& Check (P[P1], P[P4], p[p3], p[p2]) && check (P[P1], P[P2], P[P4], p[p3]) && check (P[P4], p[p2], p[p 3], P[P1]) cnt++;} cout << "Case" << cas << ":" << cnt <<Endl;}} 



FZU-2148 Moon Game

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.