福建第四届省赛

来源:互联网 发布:金融行业的大数据 编辑:程序博客网 时间:2024/04/27 02:45



Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u
Submit Status Practice FZU 2148

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

240 0100 00 100100 10040 0100 00 10010 10

Sample Output

Case 1: 1Case 2: 0

#include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>#include<cmath>#define eps 1e-8using namespace std;struct point{double x,y;}A[110];double area(point a,point b,point c){return fabs((a.x-b.x)*(c.y-b.y)-(a.y-b.y)*(c.x-b.x))/2.0;}bool judge(point a,point b,point c,point d){if(fabs(area(a,b,c)-area(a,c,d)-area(a,b,d)-area(b,c,d))<eps)return 0;if(fabs(area(a,c,d)-area(a,b,c)-area(a,b,d)-area(b,c,d))<eps)return 0;if(fabs(area(a,b,d)-area(a,b,c)-area(a,c,d)-area(b,c,d))<eps)return 0;if(fabs(area(b,c,d)-area(a,b,c)-area(a,c,d)-area(a,b,d))<eps)return 0; return 1;}int main(){int t,i,j,n,k=1;scanf("%d",&t);while(t--){scanf("%d",&n);for(i=0;i<n;++i){scanf("%lf%lf",&A[i].x,&A[i].y);}int ans=0;for(i=0;i<n;++i){for(j=i+1;j<n;++j){for(int u=j+1;u<n;++u){for(int v=u+1;v<n;++v){if(judge(A[i],A[j],A[u],A[v])&&judge(A[j],A[i],A[u],A[v])&&judge(A[u],A[i],A[j],A[v])&&judge(A[v],A[u],A[i],A[j]))ans++;}}}}printf("Case %d: %d\n",k++,ans);}return 0;}


Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u
Submit Status Practice FZU 2148

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

240 0100 00 100100 10040 0100 00 10010 10

Sample Output

Case 1: 1Case 2: 0

0 0
原创粉丝点击