【多邊形面積】 POJ 3907
【題目大意】 有若干個多邊形(不一定是凸包),按順序給出它的頂點。求這些多邊形的面積(四捨五入)。
板題。
#include<bits/stdc++.h> using namespace std; struct point{ double x,y; point(double _x=0,double _y=0){x=_x,y=_y;} friend inline double operator *(const point &a,const point &b){ return a.x*b.y-b.x*a.y; } }p[23333]; int k; int main(){ while(scanf("%d",&k)==1&&k){ double ans=0; for(int i=1;i<=k;++i) scanf("%lf%lf",&p[i].x,&p[i].y); p[k+1]=p[1]; for(int i=1;i<=k;++i){ ans+=p[i+1]*p[i]; } cout<<int(fabs(ans/2)+0.5)<<'\n'; } }
相關推薦
【多邊形面積】 POJ 3907
鐵爐堡傳送門 【題目大意】 有若干個多邊形(不一定是凸包),按順序給出它的頂點。求這些多邊形的面積(四捨五入)。 板題。 #include<bits/stdc++.h> using namespace std; struct point{ double x,y; poin
【計算凸包面積】 POJ 3348
銀月城傳送門 【題目大意】給你n個點,求它們圍出來的凸包的面積除以50【向下取整】 大概是道模板題。具體有些細節需要注意,見程式碼。 #include<cstdio> #include<cmath> #include<iostream> #includ
【補題】 POJ 3318 隨機化
tor ring cnblogs targe -a b- stdin ref () 題目鏈接:http://poj.org/problem?id=3318 題意:給你矩陣ABC,要求驗證A * B是否等於C。 思路:直接算的話復雜度n^3,妥妥TLE。 隨機化有兩種
洛谷 P1318 【積水面積】題解
能力 不難 至少 bits 表達 += body post div 其實想通了的話,本題並不難,關鍵是要**把二維分為多個一維**(大概就是這個意思,表達能力不太好,見諒!)本來一看,以為會超時,可能是數據較水吧,用這種方法還挺快的(至少沒有超時),下面是程序:```cpp
【三分】POJ - 3737 R - UmBasketella
POJ - 3737 R - UmBasketella In recent days, people always design new things with multifunction. For instance, you can not only use cell
【二分答案】POJ - 3258 C - River Hopscotch
C - River Hopscotch POJ - 3258 Every year the cows hold an event featuring a peculiar version of hopscotch that involves carefully jumpin
【二分答案】 POJ - 2456 B - Aggressive cows
B - Aggressive cows POJ - 2456 Farmer John has built a new long barn, with N (2 <= N <= 100,000) stalls. The stalls are located alo
【二分答案】POJ - 1064 A - Cable master
A - Cable master POJ - 1064 Inhabitants of the Wonderland have decided to hold a regional programming contest. The Judging Committee has
【二分答案】 POJ
Farmer John has built a new long barn, with N (2 <= N <= 100,000) stalls. The stalls are located along a straight line at position
【字尾陣列】[POJ 1743]Musical Theme
題目分析 字尾陣列模板題目,我們可以二分一下答案然後我們在構建的每兩個數的差所求得的height陣列中查詢當前連續大於mid的一個區間的pos最小和pos最大值得差值,然後如果這個差值大於了mid我們才認為可以使用,否則會因為有一個節點重疊(相當於每一個差值表
【動態規劃】[POJ 1050]To the Max
就是最大矩陣和,如果直接爆搜複雜度就是O(n4)的所以進行優化,sum[i][j][k]表示在第i列到第j列的第k行的和,那麼就列舉i, j然後最大子段和,然後就變成O(n3)了, 反正n只有100就過
【博弈 && dfs】POJ
Step1 Problem: 有 s 個石頭,有 2*n 個人,分成兩隊交叉坐著分別是 1, 3, 5,…n-1. 和 2, 4, 6,…n. 第 i 個人可以拿走不多於 a[i] 個石頭,從玩家 1 開始拿石頭 1 到 2 到 3 到….n 到 1 一
【模線性方程】POJ 2115
原文地址,感謝大神。 原文。 題目連結 題意:轉化成c * x = b - a mod (2 ^ k),解這個模線性方程的最小正整數解即可 Sample Input 3 3 2 16 3 7 2 16 7 3 2 16 3 4 2 16 0 0 0 0 Sam
【動態規劃】[POJ 1088]滑雪
意思就是把所有點存下來,按照高度排個序, 然後從小到大列舉,然後判斷當前的點的四個方向有沒有存在經過當前點更優的情況,並且那個點的高度比當前點的高度要高如果存在就更新,因為根據大小排了序,所以不會出現不會出現一個點重複統計的情況那麼複雜度是O(n2) #inc
POJ 2826 An Easy Problem?! 叉積求多邊形面積 【計算幾何】
An Easy Problem?! Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7837 Accepted: 1145 Description It's
求解多邊形面積2S= Σ【Xi (Yi+1-Yi-1)】,(i屬於1~n),公式解析及編程實現
poi logs 驗證 地圖 class view hide 對比 turn yogurt今天要個大家分享一個基礎的二維空間多邊形面積求算方法,主要也是為了下一篇《橢球體上某區域面積的求算,及Albers投影與墨卡托投影後該區域面積對比》打一個基礎。關於投影的相關過
POJ 3907 Build Your Home | 計算多邊形面積
line cstring i+1 return 多邊形 ble def != poi 給個多邊形 計算面積 輸出要四舍五入 直接用向量叉乘就好 四舍五入可以+0.5向下取整 #include<cstdio> #include<algorithm>
【POJ 3907】Build Your Home
【題目】 傳送門 Description Mr. Tenant is going to buy a new house. In fact, he is going to buy a piece of land and build his new house on it. In o
1015 - 計算幾何之多邊形的面積 - Build Your Home(POJ 3907)
傳送門 題意 順時針或逆時針給出多邊形的頂點,求該多邊形的面積 分析 很基礎…… 利用叉積的性質,每次選擇相鄰的兩個點做叉積,把答案累加起來 由於方向的問題,最後要取一個絕對值 又因為叉積算的是平行四邊形的面積,所以還要除以2
ssl1213-多邊形面積【差積,計算幾何】
正題 題目大意 求一個多邊形面積。 解題思路 隨便定一個原點,然後答案就是相鄰點的差積之和的絕對值。 要判斷不能組成多邊形的情況。 c