日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【CodeForces - 144B 】Meeting (暴力枚举,水题,计算几何)

發布時間:2023/12/10 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【CodeForces - 144B 】Meeting (暴力枚举,水题,计算几何) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題干:

The Super Duper Secret Meeting of the Super Duper Secret Military Squad takes place in a Super Duper Secret Place. The place is an infinite plane with introduced Cartesian coordinate system. The meeting table is represented as a rectangle whose sides are parallel to the coordinate axes and whose vertexes are located at the integer points of the plane. At each integer point which belongs to the table perimeter there is a chair in which a general sits.

Some points on the plane contain radiators for the generals not to freeze in winter. Each radiator is characterized by the number?ri?— the radius of the area this radiator can heat. That is, if the distance between some general and the given radiator is less than or equal to?ri, than the general feels comfortable and warm. Here distance is defined as Euclidean distance, so the distance between points?(x1,?y1)?and?(x2,?y2)?is?

Each general who is located outside the radiators' heating area can get sick. Thus, you should bring him a warm blanket. Your task is to count the number of warm blankets you should bring to the Super Duper Secret Place.

The generals who are already comfortable do not need a blanket. Also the generals never overheat, ever if they are located in the heating area of several radiators. The radiators can be located at any integer points on the plane, even inside the rectangle (under the table) or on the perimeter (directly under some general). Even in this case their radius does not change.

Input

The first input line contains coordinates of two opposite table corners?xa,?ya,?xb,?yb?(xa?≠?xb,?ya?≠?yb). The second line contains integer?n?— the number of radiators (1?≤?n?≤?103). Then?n?lines contain the heaters' coordinates as "xi?yi?ri", the numbers are separated by spaces. All input data numbers are integers. The absolute value of all coordinates does not exceed?1000,?1?≤?ri?≤?1000. Several radiators can be located at the same point.

Output

Print the only number — the number of blankets you should bring.

Examples

Input

2 5 4 2 3 3 1 2 5 3 1 1 3 2

Output

4

Input

5 2 6 3 2 6 2 2 6 5 3

Output

0

Note

In the first sample the generals are sitting at points:?(2,?2),?(2,?3),?(2,?4),?(2,?5),?(3,?2),?(3,?5),?(4,?2),?(4,?3),?(4,?4),?(4,?5). Among them, 4 generals are located outside the heating range. They are the generals at points:?(2,?5),?(3,?5),?(4,?4),?(4,?5).

In the second sample the generals are sitting at points:?(5,?2),?(5,?3),?(6,?2),?(6,?3). All of them are located inside the heating range.

題目大意:

? ? 一張長方形桌子的四個頂點全部在整數點位置,桌子的四條邊上每個整數點(x,y) (x,y都是整數)位置有一把椅子,代表有一個人,當使用加熱器在桌子周圍加熱時,問有幾個人不在加熱范圍之內。

? ? 輸入時每組數據首先給出兩個點的坐標,代表一張桌子的對角線的端點,桌子的邊與坐標軸平行,然后輸入一個n,代表有n個加熱器,接下來n行每行輸入三個數x,y,r,代表這個加熱器的坐標和加熱半徑。

解題報告:

剛開始還以為是在整個矩形內部都有點,但是看了樣例發現是在矩陣的邊上、、、所以要結合樣例理解題目啊

? ? 一個加熱器可以確定一個圓,判斷每個人是否在圓內或圓上;輸出不在圓內或圓上的人的個數即可。遍歷這個矩形的邊長跑一邊就好了,時間復雜度O(4*n^2)大概。

AC代碼:

#include<cstdio> #include<iostream> #include<algorithm> using namespace std; int x1,x2,y1,y2; int n,ans; int x[1005],y[1005],r[1005]; int main() {cin>>x1>>y1>>x2>>y2;//x1,y1,左下 cin>>n;for(int i = 1; i<=n; i++) {scanf("%d%d%d",x+i,y+i,r+i);}if(x1 > x2) swap(x1,x2);if(y1 > y2) swap(y1,y2);int j=y1;for(int i = x1; i<=x2; i++) {for(int k = 1; k<=n; k++) {if((i-x[k])*(i-x[k]) + (j-y[k])*(j-y[k]) <= r[k]*r[k]) {ans++;break;}}}j=y2;for(int i = x1; i<=x2; i++) {for(int k = 1; k<=n; k++) {if((i-x[k])*(i-x[k]) + (j-y[k])*(j-y[k]) <= r[k]*r[k]) {ans++;break;}}} j = x1;for(int i = y1 + 1; i<=y2-1; i++) {for(int k = 1; k<=n; k++) {if((i-y[k])*(i-y[k]) + (j-x[k])*(j-x[k]) <= r[k]*r[k]) {ans++;break;}}}j = x2;for(int i = y1 + 1; i<=y2-1; i++) {for(int k = 1; k<=n; k++) {if((i-y[k])*(i-y[k]) + (j-x[k])*(j-x[k]) <= r[k]*r[k]) {ans++;break;}}} // cout << ans << endl;printf("%d\n", (x2-x1+1)*2 + (y2-y1-1)*2 - ans);return 0 ; }

?

總結

以上是生活随笔為你收集整理的【CodeForces - 144B 】Meeting (暴力枚举,水题,计算几何)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 六月丁香综合 | 国产精品久久久久久久久动漫 | 国产人人看 | 无码精品人妻一二三区红粉影视 | 免费看美女隐私网站 | 大肉大捧一进一出好爽mba | 成人夜晚视频 | 亚洲第一页中文字幕 | 欧美日韩中文国产一区发布 | 免费在线观看黄色 | 神马午夜国产 | 91麻豆国产在线观看 | 国产91视频播放 | 国产精品视频a | 精品久久久久久无码人妻 | 五十路japanese55丰满 | 精品国产97 | 日本美女视频网站 | 日韩精品色| 一本一道波多野结衣av黑人 | 色图18p | 毛片中文字幕 | 亚洲精品在线视频观看 | 久久久久久91亚洲精品中文字幕 | 欧美精产国品一二三 | 国产三级精品三级在线观看 | 亚洲大胆 | 好吊在线视频 | 修仙淫交(高h)h文 | www.com污| 91麻豆网站 | 神马香蕉久久 | www.啪啪.com| 国产麻豆剧果冻传媒白晶晶 | 欧美日韩一区精品 | 欧美日韩啪啪 | 国产aa毛片 | 日本性爱视频在线观看 | 日韩在线中文 | 婷婷狠狠 | 精品久久久久久国产 | 欧美xxxxx少妇 | 国产天堂第一区 | 免费a级黄色片 | 欧美日韩一区二区视频观看 | 久久亚洲av无码西西人体 | 欧美一区二区网站 | 亚洲永久精品在线观看 | 亚洲av无码一区二区三区四区 | jizz日韩 | 思思久久久 | 野外吮她的花蒂高h在线观看 | 久久精品国产久精国产 | 欧美又粗又深又猛又爽啪啪九色 | 久久久精品影视 | 在线观看视频亚洲 | www国产精品内射老熟女 | 亚洲国产精品无码久久久久高潮 | www,jizz,com | 日本一二三区视频在线 | 激情黄色av | 国产鲁鲁视频在线观看免费 | 亚洲第一淫片 | 国产精品国语对白 | 永久精品视频 | 中文字幕最新 | 国产在线观看不卡 | 精品一区二区av | 欧美日韩亚洲国产精品 | 亚洲精品乱码久久久久久蜜桃麻豆 | chinese国产精品| 蜜桃久久精品成人无码av | 欧美影院一区 | 精品久久毛片 | 免费观看毛片 | 日韩涩| 亚洲美女色 | 色午夜婷婷 | 成年人免费在线视频 | 午夜精品99 | 特级毛片在线 | 欧美日韩免费做爰视频 | 国产精品视频在线免费观看 | 香蕉污视频 | 美女光屁屁露胸胸 | 久艹在线播放 | 炕上如狼似虎的呻吟声 | 亚洲精品一区二区三区影院忠贞 | 日本中文不卡 | 性做久久久久久久免费看 | 91丨porny丨刺激| 性高潮久久久久久 | 欧美一级黄视频 | 国产裸体永久免费无遮挡 | 免费网站黄色 | 天天色视频 | 大尺度在线观看 | 精品国产色 | 欧美动态视频 |