当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2857:Flipping Colors

题目描述

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.

输出解释

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

输入样例
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

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2857

最后修改于 2020-10-29T06:46:03+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536