Java教程

169:The Buses(翻译)

本文主要是介绍169:The Buses(翻译),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

来源:http://noi.openjudge.cn/ch0407/169/

The Buses

描述

A man arrives at a bus stop at 12:00. He remains there during 12:00-12:59. The bus stop is used by a number of bus routes. The man notes the times of arriving buses. The times when buses arrive are given.

  • Buses on the same route arrive at regular intervals from 12:00 to 12:59 throughout the entire hour.
  • Times are given in whole minutes from 0 to 59.
  • Each bus route stops at least 2 times.
  • The number of bus routes in the test examples will be <=17.
  • Buses from different routes may arrive at the same time.
  • Several bus routes can have the same time of first arrival and/or time interval. If two bus routes have the same starting time and interval, they are distinct and are both to be presented.


Find the schedule with the fewest number of bus routes that must stop at the bus stop to satisfy the input data. For each bus route, output the starting time and the interval.

输入

Your program is to read from standard input. The input contains a number n (n <= 300) telling how many arriving buses have been noted, followed by the arrival times in ascending order.

输出

Your program is to write to standard output. The output contains one integer, which is the fewest number of bus routes.

样例输入

17
0 3 5 13 13 15 21 26 27 29 37 39 39 45 51 52 53

样例输出

3

 翻译:

描述

‎一名男子于12:00抵达巴士站。他在12:00-12:59期间留在那里。巴士站由许多巴士路线使用。这名男子记下了到达公共汽车的时间。给出了公共汽车到达的时间。‎

  • ‎同一路线上的巴士在整个小时内从12:00到12:59定期到达。‎
  • ‎时间以从0到59的整分钟为单位给出。‎
  • ‎每条巴士路线至少停靠2次。‎
  • ‎测试示例中的总线路线数将会<=17。‎
  • ‎来自不同路线的巴士可能会同时到达。‎
  • ‎多条巴士路线可以具有相同的首次到达时间和/或时间间隔。如果两条公交线路具有相同的开始时间和间隔,则它们是不同的,并且都将显示。‎


‎查找必须停靠在公交车站以满足输入数据的公交线路数量最少的时间表。对于每个总线路线,输出开始时间和间隔。‎

输入

‎您的程序是从标准输入读取的。输入包含一个数字 n (n <= 300),表示已记录了多少辆到达的公共汽车,后跟按升序排列的到达时间。‎

输出

‎您的程序是写入标准输出。输出包含一个整数,这是最少的总线路线数。‎

这篇关于169:The Buses(翻译)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!