编程介的小学生 2017-01-17 05:31 采纳率: 20.5%
浏览 853
已采纳

Fourier's Lines

Description

Joseph Fourier was a great mathematician and physicist and is well known for his mathematic series. Among all the nineteen children in his family, Joseph was the youngest and the smartest. He began to show his interest in mathematics when he was very young. After he grew up, he often corresponded with C. Bonard (a professor of mathematics at Auxerre) by exchanging letters.

In one letter written to Bonard, Fourier asked a question: how to draw 17 lines on a plane to make exactly 101 crossings, where each crossing belongs to exactly two lines. Obviously, this is an easy problem, and Figure-1 is a solution that satisfies his requirement. Now the problem for you is a universal one. Can we draw N lines on a plane to make exactly M crossings, where each crossing belongs to exactly two lines? If we can, how many pieces, at most, can these lines cut the plane into?

Input

The input may have several sets of test data. Each set is one line containing two integers N and M (1 <= N <= 100, 0 <= M <= 10000), separated by a space. The test data is followed by a line containing two zeros, which indicates the end of input and should not be processed as a set of data.
Output

Output one line for each set of input in the following format:

Case i: N lines cannot make exactly M crossings.

if the drawing of these lines is impossible;

or:

Case i: N lines with exactly M crossings can cut the plane into K pieces at most.

Note: Even if N or M equals to one, you should use the words "lines" and "crossings" in your output.
Sample Input

4 3
4 6
4 2
5 11
17 101
0 0
Sample Output

Case 1: 4 lines with exactly 3 crossings can cut the plane into 8 pieces at most.
Case 2: 4 lines with exactly 6 crossings can cut the plane into 11 pieces at most.
Case 3: 4 lines cannot make exactly 2 crossings.
Case 4: 5 lines cannot make exactly 11 crossings.
Case 5: 17 lines with exactly 101 crossings can cut the plane into 119 pieces at most.

  • 写回答

1条回答

  • threenewbee 2017-01-23 15:50
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?