首页 > 其他分享 >XI Samara Regional Intercollegiate Programming Contest Problem B. Minimal Area 计算几何

XI Samara Regional Intercollegiate Programming Contest Problem B. Minimal Area 计算几何

时间:2023-04-24 23:04:44浏览次数:37  
标签:XI Contest int Regional long ans integer include define

You are given a strictly convex polygon. Find the minimal possible area of non-degenerate triangle whose
vertices are the vertices of the polygon.
Input
The first line contains a single integer n (3 ≤ n ≤ 200000) — the number of polygon vertices.
Each of the next n lines contains two integers xi and yi (−109 ≤ xi
, yi ≤ 109
) — the coordinates of polygon
vertices.
The polygon is guaranteed to be strictly convex. Vertices are given in the counterclockwise order.
Output
It is known that the area of triangle whose vertices are the integer points on the grid is either integer or
half-integer.
Output a single integer — the required area, multiplied by 2.
Examples
standard input standard output
4
0 1
3 0
3 3
-1 3
5
3
0 0
1 0
0 1
1
4
-999999991 999999992
-999999993 -999999994
999999995 -999999996
999999997 999999998
3999999948000000156
Note
It is recommended to make all calculations using integer numbers, because floating point precision most
likely would not be enough.
这次计算几何还挺简单的;
题意:给定一个严格凸多边形,求在凸多边形中找三个点,使得构成的三角形面积最小;
最后输出答案*2;
很明显是相邻的三个点组成的面积最小。。。。。那么只需要绕一圈即可

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<string>
#include<bitset>
#include<ctime>
#include<deque>
typedef long long ll;
using namespace std;
typedef unsigned long long int ull;
#define maxn 500005
#define ms(x) memset(x,0,sizeof(x))
#define Inf 0x7fffffff
#define inf 0x3f3f3f3f
const long long int mod = 1e9 + 7;
#define pi acos(-1.0)
#define pii pair<int,int>
#define eps 1e-7
#define pll pair<ll,ll>



ll quickpow(ll a, ll b) {
    ll ans = 1;
    a = a % mod;
    while (b > 0) {
        if (b % 2)ans = ans * a;
        b = b / 2;
        a = a * a;
    }
    return ans;
}

int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a%b);
}

bool prime(int x) {
    if (x == 0 || x == 1)return false;
    for (int i = 2; i <= sqrt(x); i++) {
        if (x%i == 0)return false;
    }
    return true;
}

ll x[maxn], y[maxn];
ll ans = 5e18 + 1;

ll work(ll x1, ll y1, ll x2, ll y2) {
    return abs((ll)x1*y2 - (ll)x2 * y1);
}
int main()
{
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int i, j;
    for (i = 0; i < n; i++)cin >> x[i] >> y[i];
    x[n] = x[0]; x[n + 1] = x[1];
    y[n] = y[0]; y[n + 1] = y[1];
    for (i = 0; i < n; i++) {
        ans = min(ans, work(x[i] - x[i + 1], y[i] - y[i + 1], x[i] - x[i + 2], y[i] - y[i + 2]));

    }
    cout << ans << endl;
}

标签:XI,Contest,int,Regional,long,ans,integer,include,define
From: https://blog.51cto.com/u_15657999/6221994

相关文章

  • ACM International Collegiate Programming Contest, Egyptian Collegiate Programmin
    ProblemG.GloriousStadiumInputfile:glorious.inOutputfile:standardoutputBalloonColor:OrangeAlotofpeoplewanttoattendtheWorldCup,sowewouldliketoconstructagloriousstadiumusingthefollowingalgorithm:1.Construct1stla......
  • ACM International Collegiate Programming Contest, Amman Collegiate Programming C
    Youaregivenan × mgrid,yourgoalistofindagroupoflinessuchthatthefollowingconditionsaremet:Notwolinesaretouching.Eachcellinthegridhasoneofitssidescoveredbyatleastonelineinthegroup.Alineisaborderofacellin......
  • Nordic Collegiate Programming Contest (NCPC) 2017 C 在线查询,更新
    Onehundredyearsfromnow,in2117,theInternationalCollegiateProgrammingContest(ofwhichtheNCPCisapart)hasexpandedsignificantlyanditisnowtheGalacticCollegiateProgrammingContest(GCPC).Thisyeartherearenteamsinthecontest.T......
  • The 2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest
    ThetunnelsofCuChiareanimmensenetworkofundergroundtunnelsconnectingroomslocatedintheCuChiDistrictofHoChiMinhCity.TheCuChitunnelswerethelocationofseveralmilitarycampaignsinthe1960s.Nowadays,itisapopulartouristdes......
  • ACM International Collegiate Programming Contest 2014 B SPFA 统计路径
    FloweryTrails!”()”*+,-).%”/)’0”122”1!2”342”522”!22”652”!42”72”72”5!2”!12”622”18!”162”!12”6”7”4”9”3”5”8”1”2”Inordertoattractmorevisitors,themanagerofanationalp......
  • ACM International Collegiate Programming Contest 2014 A dfs 好题
    GREAT+SWERC=PORTOWewanttohaveagreatSWERCatPortothisyearandweapproachedthischallengeinseveralways.Weevenframeditasawordadditionproblem,similartotheclassicSEND+MORE=MONEY,whereeachletterstandsforasingledigit(......
  • Numerical Approximation Chapter 6 Notes
    Weierstrasstheoremapproximation之间也有高低,所以我们在compactsubset里面会有bestapproximation.但是以polynomialinterpolation为例,随着不断选更多的Chebyshevinterpolationpoints,对应的插值多项式次数越来越高的同时也会在插值点以外的地方越来越靠近函数本身。这种情......
  • AtCoder Beginner Contest 158
    AtCoderBeginnerContest158https://atcoder.jp/contests/abc158基础不牢,地动山摇D-StringFormation一个小小的STL应用#include<bits/stdc++.h>#definelllonglongusingnamespacestd;strings;intq,t,f;charc;intmain(){cin>>s>>q......
  • ai问答:使用 Vue3 组合式API 和 TS 配置 axios 拦截器 http错误状态
    通过axios.create()可以创建一个axios实例axiosInstance,参数如下:baseURL:请求前缀timeout:超时时间headers:请求头默认配置:import{defineComponent}from'vue'importaxiosfrom'axios'exportdefaultdefineComponent({setup(){//实例-默认配置......
  • AXI DMA 设计分析
    AXIDMA架构SBIUSBIU:SlaveBusInterfaceUnit。从机总线接口模块:通过外部AHB/APB4主机访问DW_axi_dmac的内部寄存器的读写控制逻辑。从机总线接口可以通过DMAX_SLVIF_MODE参数进行配置。DMAX_SLVIF_MODE:用于从机接口的协议。AHB(0),APB4(2)根据子系统要求,可以选择......