51nod 1534 棋子游戏 博弈
![](http://file.51nod.com/images/icon/star.png)
![](http://file.51nod.com/images/icon/plus.png)
波雷卡普和瓦西里喜欢简单的逻辑游戏。今天他们玩了一个游戏,这个游戏在一个很大的棋盘上进行,他们每个人有一个棋子。他们轮流移动自己的棋子,波雷卡普先开始。每一步移动中,波雷卡普可以将他的棋子从(x,y) 移动到 (x-1,y) 或者 (x,y-1)。而瓦西里可以将他的棋子从(x,y) 移动到 (x-1,y),(x-1,y-1) 或者 (x,y-1)。当然他们可以选择不移动。
还有一些其它的限制,他们不能把棋子移动到x或y为负的座标,或者移动到已经被对手占据的座标。最先到达(0,0)的人获胜。
现在给定他们棋子的座标,判断一下谁会获胜。
Input
单组测试数据。 第一行包含四个整数xp,yp,xv,yv (0≤xp,yp,xv,yv≤10^5) ,表示波雷卡普和瓦西里棋子的座标。 输入保证他们的棋子在不同位置,而且没有棋子在(0,0)。
Output
如果波雷卡普获胜,输出Polycarp,否则输出Vasiliy。
Input示例
样例输入1 2 1 2 2
Output示例
样例输出1 Polycarp
稍微在纸上画一下就可以发现关键是能不能卡住后者的棋子让他不能斜着走 根据这个判断一下就差不多了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include <queue> #include <vector> #include <iomanip> #include <math.h> #include <map> using namespace std; #define FIN freopen("input.txt","r",stdin); #define FOUT freopen("output.txt","w",stdout); #define INF 0x3f3f3f3f #define INFLL 0x3f3f3f3f3f3f3f #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 typedef long long LL; typedef pair< int , int > PII; using namespace std; int main() { //FIN int xp, yp, xv, yv; while (~ scanf ( "%d%d%d%d" , &xp, &yp, &xv, &yv)) { int minv = min(xv, yv); int maxv = max(xv, yv); if (xp + yp <= maxv) { printf ( "Polycarp\n" ); continue ; } int flag = 0; if (xp > xv || yp > yv) { printf ( "Vasiliy\n" ); continue ; } else { printf ( "Polycarp\n" ); continue ; } } return 0; } |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步