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

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>
            亚洲国产精品成人综合| 欧美日韩激情小视频| 欧美影院精品一区| 欧美一级在线视频| 欧美一区二区三区在线免费观看| 久久久精品久久久久| 亚洲视频 欧洲视频| 亚洲欧洲一级| 亚洲一区二区毛片| 欧美专区福利在线| 欧美va亚洲va日韩∨a综合色| 亚洲电影视频在线| 日韩亚洲成人av在线| 亚洲一级免费视频| 欧美专区中文字幕| 欧美激情一区二区三区在线视频观看| 欧美日韩精品欧美日韩精品一| 国产女主播一区二区三区| 狠狠入ady亚洲精品| 99精品国产在热久久| 欧美一二区视频| 亚洲国产精选| 性色av一区二区三区| 欧美激情亚洲精品| 国产一二三精品| 99视频精品免费观看| 欧美亚洲一区二区三区| 亚洲国产高清一区二区三区| 一区二区冒白浆视频| 久久av资源网站| 欧美三区在线| 在线日韩电影| 欧美综合二区| 日韩图片一区| 久久综合五月天婷婷伊人| 国产精品v欧美精品∨日韩| 在线成人性视频| 亚洲在线观看视频网站| 亚洲第一综合天堂另类专| 午夜精品一区二区三区四区| 欧美激情综合五月色丁香小说| 黄色日韩在线| 香蕉成人久久| 一区二区毛片| 欧美三级资源在线| 亚洲精品一线二线三线无人区| 久久国产精品久久久久久| 亚洲美女免费精品视频在线观看| 久久全球大尺度高清视频| 国产一区亚洲一区| 亚洲综合社区| 亚洲网站视频| 欧美亚州一区二区三区| 在线视频亚洲欧美| 亚洲毛片一区| 欧美日韩中文字幕| 99国内精品久久| 亚洲激情欧美激情| 欧美电影在线观看完整版| 在线国产日韩| 六月婷婷久久| 久久美女性网| 最新成人av网站| 欧美国产激情二区三区| 欧美日韩成人在线| 亚洲成人在线网站| 麻豆成人精品| 麻豆国产精品一区二区三区| 亚洲国产一区二区视频| 亚洲电影av在线| 欧美久久久久久蜜桃| 亚洲先锋成人| 亚洲在线1234| 黄色成人在线| 亚洲国产成人av| 欧美日韩亚洲一区二区三区在线观看 | 奶水喷射视频一区| 激情偷拍久久| 欧美激情精品久久久久久| 欧美国产成人精品| 在线一区视频| 香蕉久久夜色精品国产| 在线观看久久av| 亚洲精品在线电影| 国产欧美精品一区| 猛干欧美女孩| 欧美另类极品videosbest最新版本| 日韩视频久久| 亚洲在线一区二区| 一区二区三区在线免费视频| 亚洲电影欧美电影有声小说| 欧美日韩激情网| 久久精品日韩欧美| 欧美搞黄网站| 久久久国产91| 欧美日本国产精品| 久久精品欧美| 欧美日本在线一区| 欧美一区成人| 欧美激情亚洲精品| 久久久久99| 欧美午夜宅男影院| 欧美成人精品福利| 国产精品日韩久久久| 欧美成人午夜激情| 国产精品一区二区三区免费观看| 欧美国产视频在线| 欧美午夜美女看片| 欧美成人免费在线观看| 国产农村妇女精品一区二区| 亚洲国产欧美日韩精品| 国产农村妇女毛片精品久久莱园子 | 亚洲一区二区三区四区在线观看 | 午夜精品国产| 女女同性精品视频| 久久久久国内| 国产精品永久免费在线| 亚洲欧洲日本mm| 影音先锋亚洲电影| 亚洲小视频在线| 日韩午夜精品视频| 裸体歌舞表演一区二区| 国产精品丝袜xxxxxxx| 韩日视频一区| 午夜国产精品视频| 午夜在线电影亚洲一区| 欧美视频中文字幕在线| 亚洲精品一区二区三| 亚洲韩日在线| 久久噜噜亚洲综合| 久久躁日日躁aaaaxxxx| 国产亚洲精品成人av久久ww| 亚洲天天影视| 亚洲一区在线播放| 欧美精品一区二| 亚洲精品免费电影| 日韩一级免费观看| 欧美精品在线观看| 亚洲国产小视频| av成人毛片| 欧美日韩综合另类| 日韩视频在线观看国产| 亚洲视频高清| 国产精品视频久久久| 亚洲图片在区色| 久久久精品动漫| 雨宫琴音一区二区在线| 久久综合免费视频影院| 亚洲高清在线观看| 亚洲久久在线| 国产精品av久久久久久麻豆网| 在线视频精品| 欧美一级专区免费大片| 国产一区视频网站| 免费毛片一区二区三区久久久| 亚洲国产精品www| 一区二区三区成人| 国产精品免费福利| 久久久久久久一区二区| 亚洲日本va午夜在线电影| 亚洲视频www| 国产色产综合色产在线视频| 可以看av的网站久久看| 日韩午夜视频在线观看| 久久se精品一区二区| 亚洲精品1区2区| 欧美午夜美女看片| 久久精品国产99国产精品| 亚洲国产裸拍裸体视频在线观看乱了中文 | 亚洲一区二区三区免费在线观看 | 久久蜜桃资源一区二区老牛| 91久久香蕉国产日韩欧美9色| 欧美日韩一区二区在线观看视频| 欧美一级日韩一级| 亚洲私人影院| 日韩午夜精品| 国产三级欧美三级日产三级99| 久久婷婷久久| 亚洲在线中文字幕| 91久久久亚洲精品| 久久精品二区亚洲w码| 99精品热6080yy久久| 激情国产一区| 国产精品免费观看视频| 久久人人爽人人| 亚洲综合精品四区| 亚洲人成亚洲人成在线观看| 久久精品在线播放| 亚洲一级免费视频| 亚洲欧洲日本专区| 国产日韩精品一区二区| 欧美日本一道本在线视频| 麻豆国产精品777777在线| 欧美在线视频观看| 一本一道久久综合狠狠老精东影业 | 亚洲欧美日韩精品久久久久 | 久久久99国产精品免费| 亚洲视频1区2区| 亚洲伦理精品| 亚洲伦理在线|