青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

ZOJ 1032 Area 2

Area 2

Time limit: 1 Seconds   Memory limit: 32768K  
Total Submit: 735   Accepted Submit: 317  

Background

Being well known for its highly innovative products, Merck would definitely be a good target for industrial espionage. To protect its brand-new research and development facility the company has installed the latest system of surveillance robots patrolling the area. These robots move along the walls of the facility and report suspicious observations to the central security office. The only flaw in the system a competitor’s agent could find is the fact that the robots radio their movements unencrypted. Not being able to find out more, the agent wants to use that information to calculate the exact size of the area occupied by the new facility. It is public knowledge that all the corners of the building are situated on a rectangular grid and that only straight walls are used. Figure 1 shows the course of a robot around an example area.

Figure 1: Example area.

Problem

You are hired to write a program that calculates the area occupied by the new facility from the movements of a robot along its walls. You can assume that this area is a polygon with corners on a rectangular grid. However, your boss insists that you use a formula he is so proud to have found somewhere. The formula relates the number I of grid points inside the polygon, the number E of grid points on the edges, and the total area A of the polygon. Unfortunately, you have lost the sheet on which he had written down that simple formula for you, so your first task is to find the formula yourself.


Input

The first line contains the number of scenarios.

For each scenario, you are given the number m, 3<=m<100, of movements of the robot in the first line. The following m lines contain pairs “dx dy” of integers, separated by a single blank, satisfying .-100<=dx, dy<=100 and (dx, dy)!=(0, 0). Such a pair means that the robot moves on to a grid point dx units to the right and dy units upwards on the grid (with respect to the current position). You can assume that the curve along which the robot moves is closed and that it does not intersect or even touch itself except for the start and end points. The robot moves anti-clockwise around the building, so the area to be calculated lies to the left of the curve. It is known in advance that the whole polygon would fit into a square on the grid with a side length of 100 units.


Output

The output for every scenario begins with a line containing “Scenario #i:”, where i is the number of the scenario starting at 1. Then print a single line containing I, E, and A, the area A rounded to one digit after the decimal point. Separate the three numbers by two single blanks. Terminate the output for the scenario with a blank line.


Sample Input

2
4
1 0
0 1
-1 0
0 -1
7
5 0
1 3
-2 2
-1 0
0 -3
-3 1
0 -3


Sample Output

Scenario #1:
0 4 1.0

Scenario #2:
12 16 19.0


Problem Source: Northwestern Europe 2001

 Analysis
Algorithm:
It is a basic computational geometry problem. For the task, the description aims us to calculate the points inner and on edge. But we can measure the area by the vector formular:
(P.S: the n+1 point is actually the first one,so  .)
Later, using the pick formulat to calculate the inner points, while the points on the edge can be counted with the move vector, which is proved to be as same as the number of  .

Code:
#include <iostream>
using namespace std;
struct delta{
    
int dx;
    
int dy;
}
;
delta move[
101];

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

int abs(int a){
    
return a>0?a:-1*a;
}

int main(){
    
int Scenario,s;
    cin
>>s;
    
for (Scenario=1;Scenario<=s;Scenario++){
        
int I=0,E=0,area=0;
        
int m;
        cin
>>m;
        move[
0].dx=0;
        move[
0].dy=0;
        
for (int i=1;i<=m;i++){
            cin
>>move[i].dx>>move[i].dy;
            E
+=gcd(abs(move[i].dx),abs(move[i].dy));
            move[i].dx
+=move[i-1].dx;
            move[i].dy
+=move[i-1].dy;
        }

        
for (i=1;i<m-1;i++){
            area
+=move[i].dx*move[i+1].dy-move[i].dy*move[i+1].dx;
        }

        area
=abs(area);
        I
=(area+2-E)/2;
        cout
<<"Scenario #"<<Scenario<<":"<<endl;
        cout
<<I<<" "<<E<<" ";
        
if (area%2) cout<<area/2+0.5<<endl;
        
else cout<<area/2<<".0"<<endl;
        cout 
<<endl;
        
for (i=1;i<=m;i++){
            move[i].dx
=0;
            move[i].dy
=0;
        }

    }

    
return 0;
}

posted on 2008-08-09 19:02 幻浪天空領主 閱讀(518) 評論(0)  編輯 收藏 引用 所屬分類: ZOJ

<2025年9月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

導航

統計

常用鏈接

留言簿(1)

隨筆檔案(2)

文章分類(23)

文章檔案(22)

搜索

最新評論

閱讀排行榜

評論排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲香蕉成视频在线观看| 亚洲美女性视频| 久久精品国产999大香线蕉| 亚洲无线一线二线三线区别av| 欧美手机在线视频| 亚洲欧美综合| 久久精品视频免费播放| 亚洲国产精品成人久久综合一区 | 国产精品捆绑调教| 欧美在线亚洲一区| 另类天堂av| 宅男噜噜噜66一区二区66| 在线综合亚洲欧美在线视频| 国产在线视频欧美一区二区三区| 欧美国产日韩免费| 国产精品扒开腿做爽爽爽软件 | av成人免费| 亚洲欧美国产77777| 亚洲国产高清在线| 亚洲视频在线看| 在线国产精品播放| 一道本一区二区| 一色屋精品视频在线观看网站| 亚洲区一区二区三区| 欧美午夜免费影院| 欧美国产欧美综合| 国产欧美日本一区视频| 欧美大片专区| 国产一区二区毛片| 日韩亚洲欧美成人| 亚洲国产精品成人精品| 先锋影音久久久| 99精品视频免费观看视频| 亚洲欧美一区二区三区极速播放 | 国产午夜亚洲精品羞羞网站 | 新67194成人永久网站| 免费久久99精品国产自| 久久国产欧美| 欧美天天综合网| 欧美激情网友自拍| 红桃视频成人| 欧美一级理论性理论a| 在线亚洲自拍| 麻豆精品一区二区综合av| 久久久999精品视频| 国产精品国产三级国产aⅴ入口| 亚洲成人在线视频播放 | 在线视频一区二区| 快射av在线播放一区| 久久国产精品久久久久久久久久 | 久久精品国产成人| 欧美中文日韩| 国产精品永久免费| 一区二区三区**美女毛片| 亚洲理论电影网| 乱人伦精品视频在线观看| 久久久夜色精品亚洲| 国产精品午夜av在线| 中文无字幕一区二区三区| 一区二区成人精品| 欧美日韩成人精品| 日韩视频在线一区二区| 亚洲人成毛片在线播放女女| 久热精品视频在线观看| 欧美成人蜜桃| 亚洲人www| 欧美日韩mp4| 99亚洲一区二区| 亚洲一区中文| 国产欧美精品在线观看| 午夜视频在线观看一区二区| 久久久久国产精品一区| 黄色成人av网站| 久久婷婷国产综合精品青草| 欧美大片18| 亚洲精品在线二区| 欧美视频中文在线看| 亚洲一区视频在线| 久久一二三国产| 亚洲国产日韩一区二区| 欧美日韩三级在线| 亚洲永久在线观看| 裸体丰满少妇做受久久99精品| 影音先锋中文字幕一区| 欧美国产先锋| 亚洲一区二区三区精品在线| 久久视频在线看| 亚洲精选在线观看| 国产精品美女在线观看| 久久国产夜色精品鲁鲁99| 亚洲激情在线| 欧美影院一区| 亚洲国产成人久久综合一区| 国产精品99免费看| 久久精品视频在线观看| 日韩天天综合| 久久久五月婷婷| av成人动漫| 一区二区自拍| 国产精品草草| 久久综合狠狠综合久久激情| 99综合电影在线视频| 久热精品视频在线观看一区| 中文精品一区二区三区| 精品动漫一区| 国产精品乱码久久久久久| 久久婷婷综合激情| 亚洲男人第一av网站| 亚洲缚视频在线观看| 久久九九精品| 亚洲午夜一二三区视频| 国产一区二区av| 欧美性猛交一区二区三区精品| 久久久青草婷婷精品综合日韩| 亚洲视频中文| 亚洲欧洲精品一区| 免费91麻豆精品国产自产在线观看 | 亚洲少妇中出一区| 91久久精品国产91性色| 久久精品久久综合| 亚洲一区在线直播| 宅男噜噜噜66一区二区| 亚洲日本va午夜在线电影| 国产一级揄自揄精品视频| 欧美午夜精品久久久久久超碰| 噜噜爱69成人精品| 久久久久久综合| 9久re热视频在线精品| 国产一区二区三区奇米久涩 | 蜜臀av一级做a爰片久久| 亚洲欧美国产不卡| 一本久道综合久久精品| 亚洲电影免费在线 | 日韩一本二本av| 亚洲欧美国产一区二区三区| 国产日韩欧美| 国产日韩欧美一二三区| 国产精品伦子伦免费视频| 欧美天堂亚洲电影院在线观看 | 国产精品成人一区二区三区夜夜夜| 免费人成精品欧美精品| 蜜桃久久av| 免费亚洲电影在线| 欧美大片第1页| 欧美激情中文字幕一区二区| 欧美成人综合| 欧美理论电影在线观看| 欧美日韩亚洲在线| 国产精品高潮呻吟久久| 国产精品自拍三区| 国产综合在线看| 精品成人a区在线观看| 影音国产精品| 亚洲人精品午夜| 日韩视频免费观看| 亚洲天堂网站在线观看视频| 亚洲欧美成人精品| 久久久久久一区二区三区| 久色婷婷小香蕉久久| 欧美激情久久久| 一区二区国产日产| 性欧美video另类hd性玩具| 久久久国产成人精品| 欧美激情bt| 国产精品五月天| 亚洲风情在线资源站| 夜夜爽www精品| 小处雏高清一区二区三区| 久热精品在线视频| 亚洲精品社区| 欧美在线观看网址综合| 免费不卡在线观看av| 国产精品高潮呻吟久久| 激情视频亚洲| 一区二区三区视频在线播放| 久久精品一区二区| 最新国产精品拍自在线播放| 亚洲一区二区三区在线看| 久久久久久一区二区三区| 欧美日韩久久精品| 国模精品娜娜一二三区| 99精品国产99久久久久久福利| 欧美一区日本一区韩国一区| 亚洲第一视频网站| 欧美亚洲自偷自偷| 欧美久久久久久蜜桃| 好吊视频一区二区三区四区 | 激情欧美丁香| 亚洲欧美激情诱惑| 亚洲国产精品成人综合| 欧美亚洲一级片| 欧美日韩在线三区| 亚洲黄色大片| 久久亚洲视频| 亚洲香蕉网站| 欧美日韩在线观看视频| 91久久精品久久国产性色也91| 久久国产精品一区二区三区四区| 一本色道久久综合亚洲精品按摩| 久久夜色精品国产|