若是凉夜已成梦

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


  • 运维

  • 前端

  • 编程

  • 随笔

  • hust-oj

1205: Problem B: Alaska

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

题目描述

Problem B: Alaska
The Alaska Highway runs 1422 miles from Dawson Creek, British Columbia to Delta Junction, Alaska. Brenda would like to be the first person to drive her new electric car the length of the highway. Her car can travel up to 200 miles once charged at a special charging station. There is a charging station in Dawson Creek, where she begins her journey, and also several charging stations along the way. Can Brenda drive her car from Dawson City to Delta Juntion and back?

输入

The input contains several scenario. Each scenario begins with a line containing n, a positive number indicating the number of charging stations. n lines follow, each giving the location of a filling station on the highway, including the one in Dawson City. The location is an integer between 0 and 1422, inclusive, indicating the distance in miles from Dawson Creek. No two filling stations are at the same location. A line containing 0 follows the last scenario.

输出

For each scenario, output a line containing POSSIBLE if Brenda can make the trip. Otherwise, output a line containing the word IMPOSSIBLE.

样例输入

2
0
900
8
1400
1200
1000
800
600
400
200
0
0

样例输出

IMPOSSIBLE
POSSIBLE

参考代码

#include <stdio.h>
#include <assert.h>
int i,j,n, s[2000];
main() 
{
    while (1 == scanf("%d",&n) && n) 
    {
        for (i=0;i<n;i++) scanf("%d",&s[i]);
        for (i=0;i<1322;) 
        {
            for (j=0;j < n && (s[j] <= i || s[j] > i+200); j++) 
            {
            }
            if (j == n) break;
            i = s[j];
        }
        if (i < 1322) printf("IMPOSSIBLEn");
      else printf("POSSIBLEn");
   }
   assert(!n);
}

解析

暂无

hustoj

发表评论 取消回复

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

*
*


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

若是凉夜已成梦

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

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

友情链接

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