问题 A: ConvexScore

题目描述

You are given N points (xi,yi) located on a two-dimensional plane. Consider a subset S of the N points that forms a convex polygon. Here, we say a set of points S forms a convex polygon when there exists a convex polygon with a positive area that has the same set of vertices as S. All the interior angles of the polygon must be strictly less than 180°.

For example, in the figure above, {A,C,E} and {B,D,E} form convex polygons; {A,C,D,E}, {A,B,C,E}, {A,B,C}, {D,E} and {} do not.
For a given set S, let n be the number of the points among the N points that are inside the convex hull of S (including the boundary and vertices). Then, we will define the score of S as 2n−|S|.
Compute the scores of all possible sets S that form convex polygons, and find the sum of all those scores.
However, since the sum can be extremely large, print the sum modulo 998244353.

Constraints
1≤N≤200
0≤xi,yi<104(1≤i≤N)
If i≠j, xi≠xj or yi≠yj.
xi and yi are integers.

 

输入

The input is given from Standard Input in the following format:
N
x1 y1
x2 y2
:
xN yN

 

输出

Print the sum of all the scores modulo 998244353.

 

样例输入

4
0 0
0 1
1 0
1 1

 

样例输出

5

 

提示

We have five possible sets as S, four sets that form triangles and one set that forms a square. Each of them has a score of 20=1, so the answer is 5.

 

题意

给定 N 个点,对于一个凸 n 边形,称其的 nn 个顶点构成一个集合 SS,并且这个多边形内及其边上有 kk 个顶点,定义这个 S 的 权值 为 2^(k−n).  求和mod;

暴力出奇迹:枚举两个顶点,看有多少个点在这两个顶点连成的线上。枚举的两个点固定,其他所有点中至少取一个,情况数就是这条线上共线的点集个数。累和,即为最终答案。

 

AC代码:

#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define ms(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;

const ll mod = 998244353;
const int maxn = 500;

ll x[maxn], y[maxn], a[maxn];

int main() {
    ll n;
    scanf("%lld", &n);
    for (int i=0; i<n; i++)
        scanf("%lld%lld", &x[i], &y[i]);
    a[0]=1;
    for(int i=1;i<=n;i++)
        a[i]=(a[i-1]<<1)%mod;
    ll ans=a[n]-1-n;
    for(int i=0;i<n;i++) {
        for(int j=0;j<i;j++) {
            int cnt=0;
            for(int k=0;k<j;k++) {
                if((x[j]-x[i])*(y[k]-y[j]) == (x[k]-x[j])*(y[j]-y[i]))
                    cnt++;
            }
            ans=(ans-a[cnt]+mod)%mod;
        }
    }
    printf("%lld\n", ans);

    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值