取金币

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

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;
}

  

最新文章

  1. 改写百度云推送SDK,PHP PEAR 包:Services_Baidu_Push
  2. QRCode.js 生成二维码
  3. 最小集合(51nod 1616)
  4. cnblog code syntaxhighlighter view
  5. 【转】Python Twisted介绍
  6. iOS 进阶 第十九天(0423)
  7. python【第九篇】多线程、多进程
  8. This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its de 错误解决办法
  9. 初学spring boot 一
  10. 一分钟掌握位运算符—与(&amp;)、非(~)、或(|)、异或(^)
  11. JavaSE_坚持读源码_Object对象_Java1.7
  12. Linux 开启端口命令
  13. 洛谷P2516 [HAOI2010]最长公共子序列(LCS,最短路)
  14. asyncio 中给running 的loop 动态添加 Future Task
  15. bootstraptable学习(2)分页
  16. DOM基础练习代码(二)
  17. c 取读地图输入
  18. 流和Variant的转换
  19. 2018年1月12日--微信小程序----出错报告(40kb的原因)---并解决方法
  20. Java基础-Collection子接口之List接口

热门文章

  1. latex bib format
  2. __tostring和__invoke 方法
  3. go语言的源码文件的分类及含义
  4. 【摘自张宴的&quot;实战:Nginx&quot;】nginx模块开发
  5. gcc 升级方法
  6. python 删除正在for循环遍历的list正确做法
  7. 1027C Minimum Value Rectangle
  8. Linux 终端命令行提示符的艺术--PS1进阶
  9. U盘刻录14.10镜像出问题的解决方法
  10. About English Web Site Font