编程介的小学生 2017-08-24 11:08 采纳率: 20.5%
浏览 664
已采纳

Find the Sequences

The sequence we discuss here is in the form a, a + b, a + 2b, a + 3b, ... where a is a non-negative integer and b is a positive integer. Your task is to find out all such sequences whose elements are of the form p3+q3 where p and q are non-negative integers.

Input:

The input consists of multiple test cases.

In each case, there're two integers n, m (3 <= n <= 10, 1 <= m <= 50). n, as mentioned above, is the number of terms in sequence, and m is the upper bound of p and q, which means 0 <= p, q <=m.

The input will be ended with "0 0" which should not be processed.

Output:

For each test case, output "Case #:" first. "#" is the number of the case, which starts from 1.

If no such sequence was found, simply output "NONE". Otherwise output the sequences in multiple lines, each line contains two integers a and b mentioned above. The sequence with smaller b comes first, if there's a tie, the one with smaller a comes first.

Separate two consecutive test cases with a blank line, but Do NOT output an extra blank line after the last one.

Sample Input:
4 10
9 1
0 0
Sample Output:
Case 1:
152 64
27 162

Case 2:
NONE

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-08-27 16:40
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料