编程介的小学生 2017-07-24 03:35 采纳率: 20.5%
浏览 695
已采纳

Lazy Pianist

Description

Music and mathematics always had a close relationship. Since Pythagoras, it is known that tonal harmony is closely related to the numerical relation of the frequencies.
A lazy pianist, that uses to play VEERY LAARGE melodies composed by Kindermann, has taken advantage of this narrow relationship. However, this pianist commonly plays only the half or a quarter of the total notes. Amazingly, the audience never has realized his trick. The main reason is that this pianist always plays melodies that have a particular characteristic that is better described by the sequence of melody shown in figure 1.

Figure 1. A sequence generated by Kindermann

As you can see, the complete sequence is:

DO DO RE DO RE RE MI DO RE RE MI RE MI MI FA DO

However, if we choose only even notes, we can obtain the following sequence:
DO DO RE DO RE RE MI DO RE RE MI RE MI MI FA DO

DO DO RE DO RE RE MI DO

This is exactly the same melody. Even more, we can observe that choosing only every fourth note, we obtain:

DO DO RE …

And, this is exactly the same melody.

The lazy pianist would like to continue playing this kind of melodies, but he does not know how to complete the melody shown in figure 1. You must construct an algorithm in order to complete that melody.
A useful tip to do the job would be to assume that every note should be represented by an integer. Thus, DO=1, RE=2, MI=3, etc. Thus, sequence presented earlier could be seen as:

A possible algorithm for generating the sequence is shown in table 1. Every decimal number is expressed by its binary representation, and then we add the number of 1's that exist in that representation. This value indicates the note.

Input

Input consists of a list of three positive integers (total, cant, pos), preceded by an integer number that means the total of cases. Where total means total of tones to generate, cant means how many tones should be shown as a result, and pos means the start point. In this way, if cant=2, and pos=1, then this mean that it is needed to generate a sequence of 2 values starting from position number one. It is not allowed that pos has a value greater than total, and obviously neither that

((pos + cant ) -1) > total.
Output

A sequence of positive integers separated by a space. Each integer means one note of the melody .
Sample Input

5
16 3 10
2 2 1
5 5 2
8 1 8
15 15 1
Sample Output

Case 1: 2 3 2
Case 2: 1 1
Case 3: It cannot be solved.
Case 4: 1
Case 5: 1 1 2 1 2 2 3 1 2 2 3 2 3 3 4

  • 写回答

1条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥20 iqoo11 如何下载安装工程模式
  • ¥15 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?