Tag Archives: 翻译

SGU 276 解题报告


276. Andrew's Troubles

time limit per test: 1 sec.
memory limit per test: 65536 KB

Famous Berland ACM-ICPC team Anisovka consists of three programmers: Andrew, Michael and Ilya. A long time ago, during the first few months the team was founded, Andrew was very often late to the trainings and contests. To stimulate Andrew to be more punctual, Ilya and Andrew decided to introduce a new rule for team participants. If somebody is late (i.e. comes at least one second after appointed time) he owes a cup of tea to other team members. If he is late for 5 minutes, he owes two cups of tea. If he is late for 15 minutes, he owes three cups of tea. And if he is late for 30 minutes or more, he owes 4 cups of tea.

著名的 Berland ACM-ICPC 团队 Anisovka 包含三名成员:Andrew, Michael and Ilya.在团队刚建立的几个月里,Andrew 经常在比赛和训练中迟到.为了激励 Andrew 更加准时, Ilya 和 Andrew 决定在团队训练中引入一条新规则.如果有人迟到(即至少比约定的时间晚一秒) 则他欠团队其他成员一杯茶.如果他迟到5 分钟,他将欠 2 杯茶.如果他迟到 15 分钟,他将欠 3 杯茶.如果迟到 15 分钟惠更多,他将欠 4 杯茶.

The training starts at the time S (counted in seconds, from some predefined moment of time) and Andrew comes at the time P (also in seconds, counted from the same moment of time).

训练开始的时间是 S (以秒作为计时单位) Andrew到达的时间是 P (同样以秒作为计时单位).

Your task is to find how many cups of tea Andrew owes.

你的任务是计算出 Andrew 一共欠多少杯茶.


Read more »

Sleeping sun歌词及翻译

Sleeping sun


The sun is sleeping quietly 太阳静静沉睡在
Once upon a century 一个世纪以前
Wistful oceans calm and red 海洋平静赤红
Ardent caresses laid to rest 已经慢慢的褪去了色彩

For my dreams I hold my life     为了梦想,我愿意付出我的生命
For wishes I behold my night 我向黑夜许愿让我看透一切
The truth at the end of time 我看清了真相
Losing faith makes a crime 它让我对自己的信仰感到迷茫

I wish for this night - time 我希望
To last for a lifetime 黑夜伴我一生
The darkness around me 黑暗包围着我
Shores of a solar sea 在日升月落的海岸
Oh how I wish to go down with the sun 我多么希望随着日落一同西沉
Sleeping Weeping With you 和你一同感受着悲伤 长眠在一起

Sorrow has a human heart 心灵上的创伤
From my god it will depart 只有靠时间抹去
I'd sail before a thousand moons 我将随着月光离去
Never finding where to go 去一个没有终点的终点
Two hundred twenty - two days of light 二百二十二天的光明
Will be desired by a night 终会被黑暗代替
A moment for the poet's play 诗人的灵感
Until there's nothing left to say 终会被磨灭

I wish for this night - time 我希望
To last for a lifetime 黑夜伴我一生
The darkness around me 黑暗包围着我
Shores of a solar sea 在日升月落的海岸
Oh how I wish to go down with the sun 我多么希望随着日落一同西沉
Sleeping Weeping With you 和你一同感受着悲伤 长眠在一起

Read more »

SGU 126 解题报告


126. Boxes

time limit per test: 0.50 sec.
memory limit per test: 4096 KB

There are two boxes. There are A balls in the first box, and B balls in the second box (0 < A + B < 2147483648). It is possible to move balls from one box to another. From one box into another one should move as many balls as the other box already contains. You have to determine, whether it is possible to move all balls into one box.

现在有两个盒子。第一个盒子有A个球,另一个盒子有B个球 (0 < A + B < 2147483648).有一种移动球的方式.从一个盒子移动球到另一个盒子,但要求被移动的球的数量要与另一个盒子已有的球的数量相同.你必须算出是否有可能将其中一个盒子清空。


The first line contains two integers A and B, delimited by space.

第一行包含两个整数 A 和 B,以空格隔开.


First line should contain the number N - the number of moves which are required to move all balls into one box, or -1 if it is impossible.

第一行输出整数 N -如果可以清空其中一个盒子所需要的移动次数,如果不可能,则输出-1.

Read more »

SGU 175 解题报告



time limit per test: 0.50 sec.
memory limit per test: 4096 KB

Let phi(W) is the result of encoding for algorithm:
1.If the length of W is 1 then phi(W) is W;
2.Let coded word is W = w1w2...wN and K = N / 2 (rounded down);
3.phi(W) = phi(wNwN-1...wK+1) + phi(wKwK-1...w1).
For example, phi('Ok') = 'kO', phi('abcd') = 'cdab'.
Your task is to find position of letter wq in encoded word phi(W).

2、设W=w1 w2 …… wN 且 K=N/2 (向下取整)
3、phi(W)=phi(wN wN-1 …… wK+1)+phi(wK wK-1 …… w1)


Given integers N, q (1 <= N <= 10^9; 1<= q <= N), where N is the length of word W.



Write position of letter wq in encoded word phi(W).


Read more »

SGU 104 解题报告


104. Little shop of flowers

time limit per test: 0.50 sec.
memory limit per test: 4096 KB

You want to arrange the window of your flower shop in a most pleasant way. You have F bunches of flowers, each being of a different kind, and at least as many vases ordered in a row. The vases are glued onto the shelf and are numbered consecutively 1 through V, where V is the number of vases, from left to right so that the vase 1 is the leftmost, and the vase V is the rightmost vase. The bunches are moveable and are uniquely identified by integers between 1 and F. These id-numbers have a significance: They determine the required order of appearance of the flower bunches in the row of vases so that the bunch i must be in a vase to the left of the vase containing bunch j whenever i < j. Suppose, for example, you have bunch of azaleas (id-number=1), a bunch of begonias (id-number=2) and a bunch of carnations (id-number=3). Now, all the bunches must be put into the vases keeping their id-numbers in order. The bunch of azaleas must be in a vase to the left of begonias, and the bunch of begonias must be in a vase to the left of carnations. If there are more vases than bunches of flowers then the excess will be left empty. A vase can hold only one bunch of flowers.

你现在想用最令人满意的方案来装饰你花店的橱窗。你有 F 束花, 每束花种类不同, 种数不超过窗台上的花瓶总数。花瓶被嵌入窗台,并且被顺序从1到 V 编号。V 表示花瓶总数。顺序编号使得1号花瓶在最左边, V 号花瓶在最右边。花束是可以移动的,而且按照不同种类从1 到 F 编号。这些编号是有特殊含义的: 编号小的花必须出现在编号大的花的左边。现在,所有的花必须按编号顺序放在花瓶中,每个花瓶对应一种花。杜鹃花必须在秋海棠左面,秋海棠必须在康乃馨前面。如果花不够,将会有花瓶是空的.

Each vase has a distinct characteristic (just like flowers do). Hence, putting a bunch of flowers in a vase results in a certain aesthetic value, expressed by an integer. The aesthetic values are presented in a table as shown below. Leaving a vase empty has an aesthetic value of 0.


V A S E S 花瓶






Bunches 花束

1 (azaleas 杜鹃花)






2 (begonias 秋海棠)






3 (carnations 康乃馨)






According to the table, azaleas, for example, would look great in vase 2, but they would look awful in vase 4.


To achieve the most pleasant effect you have to maximize the sum of aesthetic values for the arrangement while keeping the required ordering of the flowers. If more than one arrangement has the maximal sum value, any one of them will be acceptable. You have to produce exactly one arrangement.



  • 1 ≤ F ≤ 100 where F is the number of the bunches of flowers. The bunches are numbered 1 through F.
  • FV ≤ 100 where V is the number of vases.
  • -50 Aij 50 where Aij is the aesthetic value obtained by putting the flower bunch i into the vase j.
  • 1 ≤ F ≤ 100 表示花的种数。
  • FV ≤ 100 表示花瓶数。
  • -50 Aij 50 表示i号花束放入j号花瓶产生的美学价值。


  • The first line contains two numbers:F, V.
  • The following F lines: Each of these lines contains V integers,so that Aij is given as thej th number on the (j+1) st line of the input file.
  • 第一行: F, V.
  • 接下来F行每行V个数,其中Aij第(i+1) 行j 列 。


  • The first line will contain the sum of aesthetic values for your arrangement.
  • The second line must present the arrangement as a list of F numbers, so that the k’th number on this line identifies the vase in which the bunch k is put.
  • 第一行包括一个整数表示最大美学价值。
  • 第二行从左到右F个数表示最优方案的每个花束放在哪一个花瓶里,数据用空格隔开。

Read more »

SGU 184 解题报告



time limit per test: 0.50 sec.
memory limit per test: 4096 KB

Petya is well-known with his famous cabbage patties. Petya's birthday will come very soon, and he wants to invite as many guests as possible. But the boy wants everybody to try his specialty of the house. That's why he needs to know the number of the patties he can cook using the stocked ingredients. Petya has P grams of flour, M milliliters of milk and C grams of cabbage. He has plenty of other ingredients. Petya knows that he needs K grams of flour, R milliliters of milk and V grams of cabbage to cook one patty. Please, help Petya calculate the maximum number of patties he can cook.


The input file contains integer numbers P, M, C, K, R and V, separated by spaces and/or line breaks (1 <= P, M, C, K, R, V <= 10000).


Output the maximum number of patties Petya can cook.

Read more »

SGU 127 解题报告


127. Telephone directory

time limit per test: 0.50 sec.
memory limit per test: 4096 KB

CIA has decided to create a special telephone directory for its agents. The first 2 pages of the directory contain the name of the directory and instructions for agents, telephone number records begin on the third page. Each record takes exactly one line and consists of 2 parts: the phone number and the location of the phone. The phone number is 4 digits long. Phone numbers cannot start with digits 0 and 8. Each page of the telephone directory can contain not more then K lines. Phone numbers should be sorted in increasing order. For the first phone number with a new first digit, the corresponding record should be on a new page of the phone directory. You are to write a program, that calculates the minimal number P pages in the directory. For this purpose, CIA gives you the list of numbers containing N records, but since the information is confidential, without the phones locations.

CIA(中央情报局)决定为它的代理商做一份特殊的电话号码簿。号码簿的前两页是一些使用说明和人名等一些乱七八糟的内容,从第三页开始记录电话号码。每一个电话记录都只有一行,它包括两个部分:电话号码和电话位置。电话号码长度是4,电话号码不能以0或8开头。电话号码簿的每一页不能超过K行。电话号码应该按照字典序排序。第一位的数字不同的电话号码不能出现在同一页。所以当电话号码第一位改变时,应该另起一页。你需要编写一个程序,计算最少需要的页数 P。为此,CIA已经给你了一份有N条电话记录的表格,但由于工作机密,CIA没有告诉你电话的位置,所以你不用考虑电话位置。


The first line contains a natural number K (0 < K < 255) – the maximum number of lines that one page can contain. The second line contains a natural N (0 < N < 8000) – number of phone numbers supplied. Each of following N lines contains a number consisting of 4 digits – phone numbers in any order, and it is known, that numbers in this list cannot repeat.

第一行是自然数 K (0 < K < 255) 每页最多有多少行。第二行是自然数 N (0 < N < 8000) 提供的电话记录总数。 接下来的N行每行包括 4 个数字的电话号码。它们是随机顺序给出的,保证不会有重复的情况。


First line should contain a natural number P – the number of pages in the telephone directory.

输出P – 最少需要多少页。

Read more »