2240.cpp
来自「这是哈尔滨工业大学acmOJ的源代码」· C++ 代码 · 共 33 行
CPP
33 行
/* 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 + =
减小字号Ctrl + -
显示快捷键?