Gym - 100947F

本文介绍了一个简单的博弈游戏,其中两名玩家轮流移动黑白两颗棋子,目标是在对手无法移动时获胜。文章分析了游戏的制胜策略,并指出当两棋子间的距离为偶数时,先手玩家必胜。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

F. black-white
time limit per test
2 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output

Steven met his old friend Mikael yesterday and he told him about a very interesting game. The game board is made of N cells aligned in a row , and two colored stones in two different fixed positions of this row. The first stone is white, and the second is black. Steven plays with the white stone, and Mikael plays with the black one.

The two players play alternately, Each player in his turn can move his stone one cell to the right or to the left, but he cannot move it outside the board or onto a cell occupied by the other player. Steven goes first. The player who cannot make any move loses.

Steven and Mikael have become very good at playing this game, so they can know the winner of the game just by looking at the starting state of the board. Can you do the same?

You are given the initial game board and you should know who is the winner of this match, considering both players playing optimally (if both players play optimally the game will end).

Input

The first line of input is an integer T which represents the number of test cases. Each of the next T lines consists three integers N , W , B , the length of the game board , the position of the white stone , the position of the black stone (2  ≤  N  ≤  100000) (1  ≤  B , W  ≤  N)

Output

For each test case, output a single line representing its answer; if Steven is the winner output "Steven" (without quotes) otherwise"Mikael" (without quotes).

Examples
input
1
11 4 8
output
Steven

#include <bits/stdc++.h>
using namespace std;


#define LL long long
#define INF 0x3f3f3f3
#define pi acos(-1)
#define endl '\n'
#define me(x) memset(x,0,sizeof(x));
const int maxn=1e3+5;
const int maxx=1e6+5;


int T,N,W,B;
int main()
{
    cin>>T;
    while(T--)
    {
        cin>>N>>W>>B;
        if((W-B)%2==0)
            puts("Steven");
        else puts("Mikael");
    }
}



大意:看样例一猜就是一个博弈,在一行格子中,有一个白棋和一个黑旗,每次移动一个,给出一个状态,白棋先移动,问最后胜利的人是谁。

分析:只要白棋和黑棋始终保持奇数的间隔(即轮到白棋走的时候,黑白间隔奇数个),最后黑棋一定会被逼到角落,然后间隔不断减小(减小之和还是奇数间隔),最后黑棋败。

所以判断白棋和黑棋的距离是否是偶数间隔就完了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值