Java过去的时间拼图! [英] Java past time puzzle !

查看:67
本文介绍了Java过去的时间拼图!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


看看这个问题。尝试使用单个课程来回答这个课程...:


问题1:CD配音优化


现在可以使用某些功能光盘播放器允许

用户优化将光盘复制到盒式磁带。用户

指定盒式磁带的大小;播放器选择最好填充磁带第一面并播放它们的曲目,然后播放要在第二面复制的剩余磁道。

剩余曲目。您已被

CD播放器制造商聘用,以便为其型号系列实现此功能。


每张CD都提供每首曲目的曲目数和时间。

您的程序将获得此信息,并确定哪个

曲目将最好填充磁带的第一面,给定尺寸为

卡片在几分钟内。盒式磁带的尺寸分别为45,60和90分钟;

大小表示两侧磁带的总可用播放时间。


最能填充磁带第一面的曲目是

,总播放时间最接近但不超过磁带的一半

尺寸(注意 - 最适合不适合)。


您的节目输入将在几分钟内显示在录音带的一侧,并且要播放的CD上的轨道数量为

(最多17个),然后按顺序从CD上的每个曲目开始,每个曲目的时间从轨道1开始。曲目的大小和数量

曲目将出现在一行上,彼此分开按空格。

曲目时间将按顺序显示,每行一行从第一列开始,

,分钟和秒由冒号分隔。每个磁带/ CD组合将重复这个

信息,并且将通过文件结尾终止




每个组合的输出应包含五行。第一行

行包含曲目总数和磁带大小,

适当标注。第二行是包含标签Side 1:。

后面是要放在

盒式磁带第一面的曲目编号,按升序顺序用单个空格分隔。

第三行是包含边的总时间(标记为mm:ss

格式,如果秒字段需要,则前导零)。第四行

和第五行将包含第2侧相同的信息。每个组合的输出之间应出现一个空白

行。


您可能认为磁带的大小足以容纳光盘上的所有

曲目。如果有多个轨道,

将产生最佳结果,任何这样的设置都是可以接受的。


<样本输入>


45 6

7:45

11:30

0:59
3:45

9:25

2:10

60 4

15: 00

15:00

15:00

15:00



<样本输出>


C-45卡带上的6首曲目

方1:1 2 3 6

方1经过的时间22:24

Side 2:4 5

Side 2 Elapsed Time 13:10


C-60卡带上的4首曲目

Side 1:1 3

Side 1 Elapsed Time 30:00

Side 2:2 4

Side 2 Elapsed时间30:00


请将您的课程发布在代码标签中....进行评估....祝你好运!!!!

问候,

Jeff

Hi everyone,

Take a look at this problem. try to answer this program using a single class... :

Problem 1: CD Dubbing Optimization

A feature now becoming available on some compact disc players allows the
user to optimize the copying of a compact disc to cassette. The user
specifies the size of the cassette; the player selects the tracks that will
best fill the first side of the cassette and plays them, then plays the
remaining tracks to be copied on the second side. You have been hired by a
CD player manufacturer to implement this feature for their model line.

The number of tracks and time of each track is supplied on every CD.
Your program will be given this information, and is to determine which
tracks will best fill the first side of a cassette, given the size of the
cassette in minutes. Cassettes come in sizes of 45, 60, and 90 minutes; the
size represents the total usable playing time of the cassette on both sides.

The tracks which best fill the first side of the cassette are the ones
with a total playing time closest to but not greater than half the cassette
size (Take note - It is best fit NOT first fit).

Input to your program will be the side of the cassette in minutes and the
number of tracks on the CD to be played (up to 17), followed by the time of
each track on the CD in order, starting with track 1. The size and number
of tracks will appear on one line, separated from each other by spaces. The
track times will appear in order, one per line starting in the first column,
with the minutes and seconds separated from each other by a colon. This
information will be repeated for each cassette/CD combination, and will be
terminated by end-of-file.

The output for each combination should consist of five lines. The first
line is to contain the total number of tracks and the size of the cassette,
appropriately labeled. The second line is to contain the label "Side 1: "
followed by the numbers of the tracks to be placed on the first side of the
cassette, in ascending order separated from each other by single spaces.
The third line is to contain the total time for the side (labeled, in mm:ss
format, with a leading zero if needed for the seconds field). The fourth
and fifth lines are to contain the same information for side 2. One blank
line should appear between the output for each combination.

You may assume that the cassette will be large enough to hold all the
tracks on the compact disc. If there is more than one set of tracks that
will yield the best possible result, any such set will be acceptable.

<Sample Input>

45 6
7:45
11:30
0:59
3:45
9:25
2:10
60 4
15:00
15:00
15:00
15:00


<Sample Output>

6 tracks on a C-45 cassette
Side 1: 1 2 3 6
Side 1 Elapsed Time 22:24
Side 2: 4 5
Side 2 Elapsed Time 13:10

4 tracks on a C-60 cassette
Side 1: 1 3
Side 1 Elapsed Time 30:00
Side 2: 2 4
Side 2 Elapsed time 30:00


Please post your class in code tags.... for evaluation.... Good luck !!!!

Regards,
Jeff

推荐答案

这是一个binpacking问题;谷歌是你的朋友。


亲切的问候,


Jos
That''s a binpacking problem; google is your friend.

kind regards,

Jos



...


请将您的课程发布在代码标签中....进行评估....祝你好运!!!!


问候,

杰夫
...

Please post your class in code tags.... for evaluation.... Good luck !!!!

Regards,
Jeff



杰夫,你不是想让我们做你的工作,对吗?

你知道这句话是怎么说的:如果你先告诉我你的话,我会告诉你的。

; )

Jeff, you''re not trying to let us do your work, right?
You know how the saying goes: I''ll show you mine, if you show me yours first!
; )


nope,我无法显示我的答案,因为它会导致徒劳无功...... ^^


问候,

Jeff
nope, i can''t show my answer cause it will lead to futility... ^^

Regards,
Jeff


这篇关于Java过去的时间拼图!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆