2015苏州大学ACM-ICPC集训队选拔赛(1) 1006
2024-09-02 12:12:05
取金币
Time Limit : 3000/1000ms (Java/Other) Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 102 Accepted Submission(s) : 43
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
有一枚金币,其左边有a个猫粮,右边有b个猫粮,每次可以从最左或者最右取一个物品,先取到金币的一方获胜。
Input
第一行一个数T,表示测试数据组数(1 <= T <= 100)
接下来T行,每行有两个整数a和b,0 <=a, b<= 1e9
接下来T行,每行有两个整数a和b,0 <=a, b<= 1e9
Output
如果先手获胜输出“First”(引号不输出), 否则输出“Second”(引号不输出)。
Sample Input
2
0 3
1 1
Sample Output
First
Second
Author
Tong Wei
首先是个巴什博弈但又有点不同
首先 1 1 这种后手一定是胜利的,因为先手不管取哪边的猫粮,都会有一边空的,那么后手可以在空的那一边把金币拿走
当然 0 0是先手胜利
好,接下来就是一个巴什博弈了,谁先取完留下 1 1 这个状态,谁就胜利了 那么我们把两边的猫粮加起来减去2(最终状态1 1的和是2) 然后利用公式就好了
#include<stdio.h>
//#include<bits/stdc++.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<sstream>
#include<set>
#include<queue>
#include<map>
#include<vector>
#include<algorithm>
#include<limits.h>
#define inf 0x3fffffff
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
using namespace std;
int a;
int main()
{
int t;
int n,m;
while(cin>>t)
{
while(t--)
{
cin>>n>>m;
if(n==0||m==0)
{
puts("First");
}
else if(n==1&&m==1)
{
puts("Second");
}
else
{
if((n+m-2)%2!=0)
{
puts("First");
}
else
{
puts("Second");
}
}
}
}
return 0;
}
最新文章
- 改写百度云推送SDK,PHP PEAR 包:Services_Baidu_Push
- QRCode.js 生成二维码
- 最小集合(51nod 1616)
- cnblog code syntaxhighlighter view
- 【转】Python Twisted介绍
- iOS 进阶 第十九天(0423)
- python【第九篇】多线程、多进程
- This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its de 错误解决办法
- 初学spring boot 一
- 一分钟掌握位运算符—与(&;)、非(~)、或(|)、异或(^)
- JavaSE_坚持读源码_Object对象_Java1.7
- Linux 开启端口命令
- 洛谷P2516 [HAOI2010]最长公共子序列(LCS,最短路)
- asyncio 中给running 的loop 动态添加 Future Task
- bootstraptable学习(2)分页
- DOM基础练习代码(二)
- c 取读地图输入
- 流和Variant的转换
- 2018年1月12日--微信小程序----出错报告(40kb的原因)---并解决方法
- Java基础-Collection子接口之List接口