📄 2240.cpp
字号:
/* This Code is Submitted by wywcgs for Problem 2240 on 2006-05-22 at 19:26:06 */
#include <cstdio>
double wp, hp;
bool draw(double, double, double, double, double, double, bool);
int main()
{
double w, h;
int n, i, t;
for(t = 1; scanf("%lf %lf", &w, &h) != EOF && w > 1e-6; t++) {
scanf("%lf %lf %d", &wp, &hp, &n);
printf("Case %d:\n", t);
for(i = 0; i < n; i++) {
double x, y; scanf("%lf %lf", &x, &y);
printf("%s\n", draw(0, w, 0, h, x, y, true) ? "black" : "white");
}
}
return 0;
}
bool draw(double lx, double rx, double ly, double ry, double tx, double ty, bool blk)
{
double wl = (rx-lx)*wp+lx, hl = (ry-ly)*hp+ly;
int wo = (tx > wl), ho = (ty > hl), o = wo*2+ho;
if(o == 1 || o == 2) return blk;
else if(o == 0) return draw(lx, wl, ly, hl, tx, ty, !blk);
else return draw(wl, rx, hl, ry, tx, ty, !blk);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -