FZU 2148 Moon Game
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
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
Sample Output
- #include <stdio.h>
- #include <string.h>
- #include <math.h>
- #include <algorithm>
- using namespace std;
- int T;
- int n,ca=;
- int i,j,k,l;
- double x[],y[];
- double S(double x1,double y1,double x2,double y2,double x3,double y3)
- {
- double K=(x1*y2+x2*y3+x3*y1-x1*y3-x2*y1-x3*y2)/2.0;
- return fabs(K);
- }
- int check()
- {
- double S123,S124,S134,S234;
- S123=S(x[i],y[i],x[j],y[j],x[k],y[k]);
- S124=S(x[i],y[i],x[j],y[j],x[l],y[l]);
- S134=S(x[i],y[i],x[k],y[k],x[l],y[l]);
- S234=S(x[j],y[j],x[k],y[k],x[l],y[l]);
- //printf("%lf %lf %lf %lf\n",S123,S124,S134,S234);
- if(fabs(S124+S134+S234-S123)==)
- return ;
- if(fabs(S124+S134-S234+S123)==)
- return ;
- if(fabs(S124-S134+S234+S123)==)
- return ;
- if(fabs(S134+S234+S123-S124)==)
- return ;
- return ;
- }
- int main()
- {
- scanf("%d",&T);
- while(T--)
- {
- int num=;
- scanf("%d",&n);
- for(i=;i<=n;i++)
- scanf("%lf %lf",&x[i],&y[i]);
- for(i=;i<=n-;i++)
- {
- for(j=i+;j<=n-;j++)
- {
- for(k=j+;k<=n-;k++)
- {
- for(l=k+;l<=n;l++)
- {
- //printf("%d %d %d %d\n",i,j,k,l);
- if(check()==)
- num++;
- }
- }
- }
- }
- printf("Case %d: %d\n",ca++,num);
- }
- return ;
- }
FZU 2148 Moon Game的更多相关文章
- ACM: FZU 2148 Moon Game - 海伦公式
FZU 2148 Moon Game Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64 ...
- FZU 2148 moon game (计算几何判断凸包)
Moon Game Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit St ...
- FZU 2148 Moon Game --判凹包
题意:给一些点,问这些点能够构成多少个凸四边形 做法: 1.直接判凸包 2.逆向思维,判凹包,不是凹包就是凸包了 怎样的四边形才是凹四边形呢?凹四边形总有一点在三个顶点的内部,假如顶点为A,B,C,D ...
- FZOJ Problem 2148 Moon Game
Proble ...
- fzu Problem 2148 Moon Game(几何 凸四多边形 叉积)
题目:http://acm.fzu.edu.cn/problem.php?pid=2148 题意:给出n个点,判断可以组成多少个凸四边形. 思路: 因为n很小,所以直接暴力,判断是否为凸四边形的方法是 ...
- FZU Problem 2148 Moon Game (判断凸四边形)
题目链接 题意 : 给你n个点,判断能形成多少个凸四边形. 思路 :如果形成凹四边形的话,说明一个点在另外三个点连成的三角形内部,这样,只要判断这个内部的点与另外三个点中每两个点相连组成的三个三角形的 ...
- 暴力(判凸四边形) FZOJ 2148 Moon Game
题目传送门 题意:给了n个点的坐标,问能有几个凸四边形 分析:数据规模小,直接暴力枚举,每次四个点判断是否会是凹四边形,条件是有一个点在另外三个点的内部,那么问题转换成判断一个点d是否在三角形abc内 ...
- Moon Game (凸四边形个数,数学题)
Problem 2148 Moon Game Accept: 24 Submit: 61 Time Limit: 1000 mSec Memory Limit : 32768 KB Pro ...
- FZU-2148-Moon Game,,几何计算~~
Problem 2148 Moon Game Time Limit: 1000 mSec Memory Limit : 32768 KB Problem Description Fat brothe ...
随机推荐
- 夺命雷公狗—angularjs—17—angularjs的静态库
在实际的开发中我们往往已经离不开我们的静态库了,因为那里面有太多强悍的功能了,比如路由都是通过一个angular-route的库来实现的,, 那个库,我们可以在百度静态资源公共库来查找,查找方法如下所 ...
- Sqlserver 平面文件导入/ SSIS FlatFileSource导入文件时 出现LocaleID is not installed报错问题
最近在使用SqlServer和SSIS导入一个CSV文件到数据库时(SSIS选用的FlatFileSource作为数据流源),老是遇到 The LocaleID 4 is not installed ...
- Openstack的ping不通实例的解决办法
状态:实例在管理平台上正常创建,也能vnc到实例里面使用ifconfig,查看IP得到我们想要的IP,但是在除了计算节点以外的机器ping实例就是不通. 操作:主要为了测试网络51删除,重新创建网络5 ...
- c++实现mlp神经网络
之前一直用theano训练样本,最近需要转成c或c++实现.在网上参考了一下其它代码,还是喜欢c++.但是看了几份cpp代码之后,发现都多少有些bug,很不爽.由于本人编码能力较弱,还花了不少时间改正 ...
- android 项目学习随笔七(ViewPagerIndicator与ViewPager)
1.ViewPagerIndicator https://github.com/JakeWharton/ViewPagerIndicator package com.viewpagerindicato ...
- HTTP错误汇总(404、302、200……)
HTTP 400 - 请求无效HTTP 401.1 - 未授权:登录失败HTTP 401.2 - 未授权:服务器配置问题导致登录失败HTTP 401.3 - ACL 禁止访问资源HTTP 401.4 ...
- 160826、浏览器渲染页面过程描述,DOM编程技巧以及重排和重绘
一.浏览器渲染页过程描述 1.浏览器解析html源码,然后创建一个DOM树. 在DOM树中,每一个HTML标签都有一个对应的节点(元素节点),并且每一个文本也都有一个对应的节点(文本节点). DO ...
- nginx+tomcat负载均衡+动静分离+redis集中管理session
1.服务器A安装ng,服务器B.C安装tomcat: 2.服务器A建立/data/www目录,用于发布静态文件: 3.ng无动静分离配置: user root root; worker_process ...
- Dynamics AX 2012 R2 切换环境后项目导入报错
Reinhard重装了服务器.重装后,导入项目A报错,错误提示如下: A table, Extended Data Type, Base Enum or class called ???? a ...
- 高级工具gprof、gprof2dot.py、dot
可以研究程序性能.函数调用堆栈等,而且能用图标查看. linux环境下 C++性能测试工具 gprof + kprof + gprof2dot - 阁子 - 博客园 gprof.gprof2dot.p ...