10225_Fourier'sLines

2022-5-16 18:16| 发布者: Hocassian| 查看: 54| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89504676611099-Problem List-采集的数据-后羿采集器.html

Pro.ID

10225

Title

Fourier's Lines

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=10225

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others)
  • 描述

    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?

    输入

    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.

    输出

    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.

    Source

    样例输入

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

    样例输出

    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.

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部