Moon Game

6 篇文章 0 订阅

Think:
不得不说 水出 这题是 特别有成就感~~~~~~~ 但是 怼了 好久 !!!!!!!!前面的英语是 废话!!! 就是让我们数 凸四边形的个数TAT , 直接枚举暴力 过~~~~~

主要想法:
因为 不是 凸四边形 就是 凹四边形, 所以 就用 凹四边形的面积来算个数。
在凹四边形中 必定 有一点在内部, 所以 就可以 得出面积关系 eg Sabc = Sabd + Sacd + Sbcd; 只要不满足 这个关系的 就是 凸四边形~~~~~~~~
K函数的目的是 算出面积, flag函数的目的是判断。。。。

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
2
4
0 0
100 0
0 100
100 100
4
0 0
100 0
0 100
10 10
Sample Output
Case 1: 1
Case 2: 0

#include<iostream>
#include<cstdio>
using namespace std;
struct node
{
    int x;
    int y;
}a[10086];

//a b c d ====>  abc abd acd bcd

double K(struct node A, struct node B, struct node C)
{
   double ans;
   ans = (1.0 * (B.x - A.x) * 1.0 * (C.y - A.y) - 1.0 * (C.x - A.x) * 1.0 * (B.y - A.y))/ 2.0;
   if (ans < 0) ans = -ans;
   return ans;
}

bool flag(struct node  A, struct node B, struct node C, struct node D)
{
     double ans;
     ans = K(A, B, C) - K(A, B, D) - K(A, C, D) - K(B, C, D);
     if (ans < 0) ans = -ans;
     if (ans <= 1e-6)
        return false;
     else
        return true;
}


int main()
{
    int kase = 0;
    int i, j, k, t;
    int T;
    int cnt;
    cin >> T;
    while(T --)
    {
        int n;
        cin >> n;
        kase ++;
        cnt = 0;
        for (i = 0; i <= n - 1; i ++)
            cin >> a[i].x >> a[i].y;

        for (i = 0; i <= n - 1; i ++)
            for (j = i + 1; j <= n - 1; j ++)
                for (k = j + 1; k <= n - 1; k ++)
                    for (t = k + 1; t <= n - 1; t ++)
                    {
                        if (((flag(a[i], a[j],a[k],a[t])&& flag(a[i], a[t], a[k],a[j])) &&(flag(a[i], a[j], a[t], a[k])&& flag(a[t], a[j], a[k],a[i]))))
                                    cnt ++;
                        }
        printf("Case %d: %d\n", kase, cnt);
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Zero Moon 是 ZeroTier 网络的中心控制器,它允许您创建和管理 ZeroTier 网络。下面是 ZeroTier Moon 的搭建步骤: 1. 安装 ZeroTier Moon 可以通过以下命令安装 ZeroTier Moon: ``` curl -s 'https://install.zerotier.com/moon.sh' | sudo bash ``` 这将自动下载并安装 ZeroTier Moon。 2. 配置 ZeroTier Moon ZeroTier Moon 的配置文件位于 /var/lib/zerotier-one/zerotier-moon.ini。可以使用文本编辑器打开并修改它。 下面是一个简单的示例配置: ``` [moon] # ZeroTier Moon Server ID (16 hex digits) id = 0123456789abcdef # API access token api-token = YOUR_API_TOKEN # IP address for Moon virtual network (CIDR notation) network = 10.147.17.0/24 # Port for Moon virtual network port = 9993 ``` 请将 YOUR_API_TOKEN 替换为一个随机字符串,以确保安全。 3. 启动 ZeroTier Moon 可以使用以下命令启动 ZeroTier Moon: ``` sudo systemctl start zerotier-moon ``` 4. 配置 ZeroTier 客户端 要连接到 ZeroTier Moon,您需要在客户端上安装 ZeroTier 并加入网络。 可以使用以下命令在 Ubuntu 上安装 ZeroTier: ``` sudo apt-get install zerotier-one ``` 安装完成后,使用以下命令加入 ZeroTier 网络: ``` sudo zerotier-cli join YOUR_NETWORK_ID ``` 请将 YOUR_NETWORK_ID 替换为您的 ZeroTier 网络 ID。 5. 确认连接 在 ZeroTier Moon 上,您应该能够看到客户端连接的信息。可以使用以下命令查看连接信息: ``` sudo zerotier-cli listnetworks ``` 如果一切正常,您应该能够看到客户端的 IP 地址。 这就是 ZeroTier Moon 的搭建步骤。希望对您有所帮助!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值