CF533C:Board Game(博弈)

C. Board Game
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1, y) or (x, y - 1). Vasiliy can move his pawn from (x, y) to one of cells: (x - 1, y), (x - 1, y - 1) and (x, y - 1)Both players are also allowed to skip move.

There are some additional restrictions — a player is forbidden to move his pawn to a cell with negative x-coordinate or y-coordinate or to the cell containing opponent's pawn The winner is the first person to reach cell (0, 0).

You are given the starting coordinates of both pawns. Determine who will win if both of them play optimally well.

Input

The first line contains four integers: xp, yp, xv, yv (0 ≤ xp, yp, xv, yv ≤ 105) — Polycarp's and Vasiliy's starting coordinates.

It is guaranteed that in the beginning the pawns are in different cells and none of them is in the cell (0, 0).

Output

Output the name of the winner: "Polycarp" or "Vasiliy".

Examples
input
2 1 2 2
output
Polycarp
input
4 7 7 4
output
Vasiliy
Note

In the first sample test Polycarp starts in (2, 1) and will move to (1, 1) in the first turn. No matter what his opponent is doing, in the second turn Polycarp can move to (1, 0) and finally to (0, 0) in the third turn.


思路:如果p的横纵坐标小于等于v坐标,则p必赢,因为p可以沿着v的斜路线进行拦截;否则判断谁的路径最短即可。

# include <stdio.h>
int main()
{
    int x1, y1, x2, y2, m1, m2;
    while(~scanf("%d%d%d%d",&x1,&y1,&x2,&y2))
    {
        if(x1 <= x2 && y1 <= y2)
            puts("Polycarp");
        else
        {
            m1 = x1 + y1;
            m2 = x2>y2?x2:y2;
            if(m1 <= m2)
                puts("Polycarp");
            else
                puts("Vasiliy");
        }
    }
    return 0;
}



转载于:https://www.cnblogs.com/junior19/p/6729922.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值