编程介的小学生 2019-10-04 21:50 采纳率: 20.5%
浏览 96

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)