ACM Runway Planning

2024-02-03 04:08
文章标签 acm planning runway

本文主要是介绍ACM Runway Planning,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

题目:

Most airports have multiple runways. To identify runways, they are given a number indicat- ing the direction of the runway. Such a runway number is obtained by dividing the heading of the runway in degrees by ten, rounding the result, and optionally prefixing it with a ‘0’ if the result has only a single digit. For example, a runway with a heading of 82° is indicated by the number 08.If you are paying attention, you might think “a runway can be used in both directions, and therefore has two headings, but it is only assigned one runway number.” You are correct: normally a runway is identified by two numbers, based on the direction in which the runway is used. To simplify matters, we only concern ourselves with the smallest of these two num- bers, except if it is zero; we then use 18 instead. The runway numbers thus range from 01 to 18.

Now, you might think, “what if two runways have the same heading?” In that case, the characters ‘L’ and ‘R’ are appended to the number of the left and right runway, respectively. But what if three runways have the same heading? Then, the character ‘C’ is appended to the center runway. “But”, I can hear you ask, “what if four runways have the same heading?” If you really want to know, look up how Dallas/Fort Worth International Airport solved this problem after the contest. At any rate, we do not concern ourselves with multiple runways having the same heading in this problem, so you can forget all you read in this paragraph.

The runway in use is mostly determined by the current direction of the wind. It is pre- ferred to take off and land with headwind. If it is not possible to have the wind coming from straight ahead, its direction should be as close to that as possible. For example, if an airport has the runways 05 and 15, and the wind has a heading of 70°, taking off and landing using runway 05 is preferred, since the heading of that runway is closest to the heading of the wind.

Now, consider an airport already having one or more runways, and planning the con- struction of a new runway. Obviously, this runway should have a unique runway number: not only would we otherwise have a problem outside the boundaries of our restricted runway numbering outlined above, but, most importantly, this increases the probability of being able to take off or land with headwind.

The engineers at the airport under consideration have already determined the heading of the new runway, but still need you to determine the runway number. Note that the engineers are not very considerate with their input to your problem. They give you one heading of the runway, but it can be either the lowest or the highest heading of the runway. Be sure to give the lowest of the two runway numbers, as discussed in the second paragraph of this problem statement, even if you are given the highest of the two headings from the engineers.

输入格式

On the first line one positive number: the number of test cases, at most 100. After that per test case:

  • one line with a single integer hh (1 \leq h \leq 3601h360): the heading of the new runway in degrees.

输出格式

Per test case:

  • one line with the runway number of the newly constructed runway.
样例输入
4
82
115
316
4
样例输出
08
12
14
18

题意:

让你给每个对应的角度编号,题目中说了范围是01-18,因此会有一个对18的取模,之后又说除以10并且四舍五入,因此题意就是不断的除以10四舍五入然后减去18继续上述操作(就是直接对18取模了)

代码:

#include<stdio.h>
using namespace std;
int main()
{
    int k,n;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d",&k);
        k=((k+5)/10)%18;//整数的四舍五入就直接加上5;
        if(k==0) printf("18\n");
        else printf("%02d\n",k);
    }
    return 0;
}

这篇关于ACM Runway Planning的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/672947

相关文章

认识、理解、分类——acm之搜索

普通搜索方法有两种:1、广度优先搜索;2、深度优先搜索; 更多搜索方法: 3、双向广度优先搜索; 4、启发式搜索(包括A*算法等); 搜索通常会用到的知识点:状态压缩(位压缩,利用hash思想压缩)。

【转载】ACM感悟

今天看了一篇我们学校前辈的ACM的感悟,觉得写的十分有道理,这里转载,文章还会不断的改进和更新。 原文链接:http://www.cnblogs.com/Chierush/p/3760870.html?ADUIN=1339764596&ADSESSION=1401536826&ADTAG=CLIENT.QQ.5329_.0&ADPUBNO=26349 声明:本文是写给弱校ACM新手的一点

我们依旧在追梦的路上-山东省第六届ACM比赛总结

这场比赛从结果而言达到了预期(金牌),从过程而言和我的预期相差甚远(打的太乱,个人发挥很差),还好关键时刻队友抗住压力,负责后果真的不堪设想。 热身赛 热身赛纯粹测机器的,先把A,B,C草草水过(A题小写x打成大写的也是醉了),我和老高开始各种测机器,long long不出所料是lld的,试了一下除0和数组越界的re问题,发现没有re,只有wa(甚至数组越界还AC了),至于栈深的话也没过多追

ACM东北地区程序设计大赛

不得不说随着参赛级别的提高,题目真的是越来越难啊,不过队长真是给力啊,在我们三个共同努力之下拿下了地区赛三等奖,哈哈我们可是大一唯一一只获奖队,终于在这次比赛打败了田大神。。。大神是失手了,俺和他差距还是挺大的。。。队友陈彤马上要去服兵役了,他说这是我们送给他最好的离别礼物,希望那家伙在部队好好干,以后谁干揍我!!!东北地区赛结束后,今年已经估计没机会参加亚洲区比赛了,赶紧补高数和线数啊!!别挂了

ACM比赛中如何加速c++的输入输出?如何使cin速度与scanf速度相当?什么是最快的输入输出方法?

在竞赛中,遇到大数据时,往往读文件成了程序运行速度的瓶颈,需要更快的读取方式。相信几乎所有的C++学习者都在cin机器缓慢的速度上栽过跟头,于是从此以后发誓不用cin读数据。还有人说Pascal的read语句的速度是C/C++中scanf比不上的,C++选手只能干着急。难道C++真的低Pascal一等吗?答案是不言而喻的。一个进阶的方法是把数据一下子读进来,然后再转化字符串,这种方法传说中

2014年ACM/ICPC亚洲区现场赛广州赛区总结

本来不想提这件事的,后来学姐找我谈心时提到这件事,我突然意识到在这件事情上我错了一次,明明答应的去参加这场比赛,最后临时决定不去......其实中间有很多很多原因 1:我和tyh,sxk临时不去主要是广州太远,我们身上money不够,呵呵。。。别笑我们,你以为我们是高富帅啊,去一趟广州消费要2个月的生活费,奖学金又没发,你让我找我妈要她辛辛苦苦挣来的工资吗?!从哈尔滨到广州单来回的火车票每个人就

【UVa】10600 ACM Contest and Blackout 次小生成树

类型:次小生成树 题目大意: 为了举办ACM竞赛,市长决定给所有的n(3 <= n <= 100)所学校提供可靠的电力供应。当且仅当一个学校直接连到电站,或者连到另一个有可靠供应的学校时,才有可靠供应。现在给出在不同学校之间的布线成本,找出最便宜的两种连线方案。一个方案的成本等于其中所有学校之间连线的成本的总和。 题目分析: 次小生成树。 先求出最小生成树,然后枚举所有不在

acm 学习总结

最近也是新做了几个题目有的通过看题解然后自己敲出来一遍一遍的修改对动态规划也是有了点认识在拿到一个题目考虑他的思路时如果没法找到每个子问题之间的关系并且用数组将他们记忆就说明这个思路是错的而且题目有很多都是根据一个知识点不断的变式。每种类型的题也都有模板最近我在专门看这些模板,模板看的我也是一脸懵,其实我觉得模板这东西说好也好说不好也不好,好的时候你看出来哪种题适合哪种模板套进去题目就ac了,但是

ACM STL之vector

vector 是向量 也成动态数组既数组的大小可以根据数据自动变化。使用时要包含头文 定义 vector<类型>变量名; 初始化 vectora; vectorb(a);把a的所有元素给b(必须要同类型)。/vectorb=a; vectora(n,m);a包含n个元素每个元素都为m。 vectora(n);包含n个元素初始化为0。 vectora{b,c,d,e,f};包含花括号中个数的元素,每

ACM STL之map

map是一个容器,里面存储的是 pair 由key和value组成 key称为关键字(对应first)value称为键值(对应second) key值不能重复map中的元素按key升序排列(省了sort)。 头文件 #include 定义 map<int,int>a; 迭代器 map<string,int>::iterator it; 用迭代器调key 和value的用法 it->first it