博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
FZU Moon Game(几何)
阅读量:5152 次
发布时间:2019-06-13

本文共 2658 字,大约阅读时间需要 8 分钟。

Accept: 710    Submit: 2038
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-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 
#include
#include
#include
#include
#include
using namespace std;struct Node{ int x; int y;}a[5],b[35];int s[10];int top;int cross(Node a,Node b,Node c){ return (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x);}int dis(Node a,Node b){ return sqrt((double)(a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}int cmp(Node p1,Node p2){ int temp=cross(a[0],p1,p2); if(temp>0) return true; else if(temp==0&&dis(a[0],p1)
2) { top=1;s[0]=0;s[1]=1; for(int i=2;i
0&&cross(a[s[top-1]],a[s[top]],a[i])<=0) top--; s[++top]=i; } return top; }}int n;int main(){ int t; scanf("%d",&t); int cas=0; int ans=0; while(t--) { scanf("%d",&n); ans=0; for(int i=1;i<=n;i++) scanf("%d%d",&b[i].x,&b[i].y); for(int i=1;i<=n;i++) { for(int j=i+1;j<=n;j++) { for(int k=j+1;k<=n;k++) { for(int p=k+1;p<=n;p++) { a[0]=b[i];a[1]=b[j];a[2]=b[k];a[3]=b[p]; sort(a,a+4,cmp2); sort(a+1,a+4,cmp); //cout<
<<" "<
<<" "<
<<" "<

<

转载于:https://www.cnblogs.com/dacc123/p/8228723.html

你可能感兴趣的文章
Python核心编程——多线程threading和队列
查看>>
Program exited with code **** 相关解释
查看>>
植物大战僵尸中文年度版
查看>>
26、linux 几个C函数,nanosleep,lstat,unlink
查看>>
投标项目的脚本练习2
查看>>
201521123107 《Java程序设计》第9周学习总结
查看>>
Caroline--chochukmo
查看>>
算法导论笔记 第8章 线性时间排序
查看>>
利用jquery的contains实现搜索功能
查看>>
iOS之文本属性Attributes的使用
查看>>
从.Net版本演变看String和StringBuilder性能之争
查看>>
Excel操作 Microsoft.Office.Interop.Excel.dll的使用
查看>>
解决Ubuntu下博通网卡驱动问题
查看>>
【bzoj2788】Festival
查看>>
执行gem install dryrun错误
查看>>
Java SE之正则表达式一:概述
查看>>
HTML5简单入门系列(四)
查看>>
实现字符串反转
查看>>
转载:《TypeScript 中文入门教程》 5、命名空间和模块
查看>>
苹果开发中常用英语单词
查看>>