codeforces 493 D Vasya and Chess【 博弈 】
2015-06-29 13:10
323 查看
题意:给出n*n的棋盘,白方在(1,1),黑方在(1,n)处,每一步可以上下左右对角线走,哪个先抓到另一个,则它获胜
可以画一下,发现n是奇数的时候,白方先走,无论它怎么走,黑方和它走对称的,黑方都一定能赢
n是偶数的时候,将白方走到(1,2)就变成奇数的情况,白方必胜
View Code
可以画一下,发现n是奇数的时候,白方先走,无论它怎么走,黑方和它走对称的,黑方都一定能赢
n是偶数的时候,将白方走到(1,2)就变成奇数的情况,白方必胜
#include<iostream> #include<cstdio> #include<cstring> #include <cmath> #include<stack> #include<vector> #include<map> #include<set> #include<queue> #include<algorithm> using namespace std; typedef long long LL; const int INF = (1<<30)-1; const int mod=1000000007; const int maxn=1000005; int main(){ int n; scanf("%d",&n); if(n&1) puts("black"); else printf("white\n1 2\n"); return 0; }
View Code
相关文章推荐
- struts的优缺点
- React-Native入门指南(一)——环境配置 & Hello World
- 最帅的WebLogic10安装图文教程
- 如果你知道什么是用户,那么你打败了全国90%的人
- Cordys Business Identify 的使用
- 求职技巧—2014六个秘诀二 - 年求职
- 设计模式--浅谈原型模式
- SAT填空题答题的两个注意事项介绍
- 黑马程序员——Java基础——IO流(下)
- #308 (div.2) B. Vanya and Books
- 好网站
- jstree刷新
- 黑马程序员-OC语言-#pragma mark指令的使用(听课笔记)
- ios UIBarButtonItem rightBarButtonItem Title 设置不了
- php使用逆波兰算法实现四则运算器
- 教程——Basys3开发板实现示波器设计
- Android 基于google Zxing实现二维码、条形码扫描
- DBA成长箴言
- 解决Determining ip information for eth0... failed
- angularjs ajax post跨域提交数据