若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。


  • 运维

  • 前端

  • 编程

  • 随笔

  • hust-oj

1106: Problem B: Saskatchewan

发表于 2017-10-06   |   分类于 HUSTOJ   |   阅读次数 1,249

题目描述

Problem B: Saskatchewan
The province of Saskatchewan is surveyed in sections. A section is a square mile of land. Grid roads delimit sections; there is one north-south and one east-west road exactly every mile. (Complications arise because of the curvature of the earth but you can disregard these and assume that the province is a plane.) The provincial border is a polygon whose vertices correspond to the intersections of grid roads. However, the edges do not necessarily follow grid roads; some sections are cut by the border. Your job is to compute how many sections are completely within a province like Saskatchewan.
Standard input contains a series of no more than 100 coordinate pairs, one pair per line. These coordinates give the vertices of the perimeter of the province; the border is formed by connecting them in order. All coordinates are in the first quadrant; they range from 0 to 100,000.
Your output should be a single integer: the number of sections (i.e. unit squares with corners at integer coordinates) fully contained within the province.

输入

暂无

输出

暂无

样例输入

0 0
0 100000
99999 100000
100000 0

样例输出

9999900000

参考代码

#include <stdio.h>
#include <stdlib.h>
char in[5000];
int i,j,k,n,next,prev,jolly;
main() 
{
    while (1 == scanf("%d",&n)) 
    {
        jolly = 1;
        for (i=1;i<n;i++) in[i] = 0;
        scanf("%d",&prev);
        for (i=1;i<n;i++) 
        {
            scanf("%d",&next);
            j = abs(next-prev);
            if (j < 1 || j >= n || in[j]++) jolly = 0;
            prev = next;
        }
        if (jolly) printf("Jollyn");else printf("Not jollyn");
   }
}

解析

暂无

hustoj

发表评论 取消回复

电子邮件地址不会被公开。 必填项已用*标注

*
*


hoxis wechat
著作权归作者所有
站点更新说明
  • 文章目录
  • 站点概览
若是凉夜已成梦

若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。

1904 日志
6 分类
12 标签
RSS
weibo github twitter facebook

友情链接

Dreams孤独患者 Skip 原站点
© 2017 若是凉夜已成梦
Powered by WordPress | 已运行
Theme By NexT.Mist