Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit 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.
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.
#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 & %I64uSubmit 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.
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.
0 0