21118_Flippingcolors

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

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

Pro.ID

21118

Title

Flipping colors

Title链接

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

AC

5

Submit

7

Ratio

71.43%

时间&空间限制

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

    A rectangle with sides parallel to the x-y axes and its left-lower corner at (0, 0) is being painted. The rectangle may be thought of as a flat-screen display with almost infinite resolution; initially the entire rectangle is black. Two numbers are given 0 < h, v < 1 and then

    • A vertical line is drawn dividing the horizontal sides of the rectangle in proportion h:1-h from the left.

    • A horizontal line is drawn dividing the vertical sides of the rectangles in proportion v:1-v from the bottom up.

    • These two lines divide the rectangle into four smaller rectangles.

    • The upper left and the lower right sub-rectangles remain intact.

    • The color of the other two rectangles is flipped (from black to white or from white to black) and now each of them is subject to the operation just performed on the bigger rectangle.

    • This process continues (in principle) forever.

    Given a point in the original rectangle but not on the boundary of any rectangle that turns up in the process of painting, determine the color of the point.

    输入

    Input contains multiple cases. The first line of each case contains 4 numbers, the length of the rectangle H, the height of the rectangle V and then the numbers h and v. The next line contains one integer number n, the number of points to consider. The following n lines contain two numbers each, the x and the y coordinate of a point.

    输出

    Description

    A rectangle with sides parallel to the x-y axes and its left-lower corner at (0, 0) is being painted. The rectangle may be thought of as a flat-screen display with almost infinite resolution; initially the entire rectangle is black. Two numbers are given 0 < h, v < 1 and then

    • A vertical line is drawn dividing the horizontal sides of the rectangle in proportion h:1-h from the left.

    • A horizontal line is drawn dividing the vertical sides of the rectangles in proportion v:1-v from the bottom up.

    • These two lines divide the rectangle into four smaller rectangles.

    • The upper left and the lower right sub-rectangles remain intact.

    • The color of the other two rectangles is flipped (from black to white or from white to black) and now each of them is subject to the operation just performed on the bigger rectangle.

    • This process continues (in principle) forever.

    Given a point in the original rectangle but not on the boundary of any rectangle that turns up in the process of painting, determine the color of the point.

    Input

    Input contains multiple cases. The first line of each case contains 4 numbers, the length of the rectangle H, the height of the rectangle V and then the numbers h and v. The next line contains one integer number n, the number of points to consider. The following n lines contain two numbers each, the x and the y coordinate of a point.

    Output

    Organize your output as shown in the sample. For each point from input print the color of the point.

    Sample Input

    81 32 0.333333333333 0.5
    6
    16 30
    16 25
    16 12.0001
    16 11.9999
    16 7.987654321
    16 7.0123456789
    10 10 0.123456789 0.987654321
    2
    0.432 0.9876
    9.432 0.9876
    0 0 0 0

    Sample Output

    Case 1:
    black
    black
    white
    black
    white
    white
    Case 2:
    white
    black

    Source

    样例输入

    81 32 0.333333333333 0.5
    6
    16 30
    16 25
    16 12.0001
    16 11.9999
    16 7.987654321
    16 7.0123456789
    10 10 0.123456789 0.987654321
    2
    0.432 0.9876
    9.432 0.9876
    0 0 0 0

    样例输出

    Case 1:
    black
    black
    white
    black
    white
    white
    Case 2:
    white
    black

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部