time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Anna and Katie ended up in a secret laboratory.
There are a+b+c�+�+� buttons in the laboratory. It turned out that a� buttons can only be pressed by Anna, b� buttons can only be pressed by Katie, and c� buttons can be pressed by either of them. Anna and Katie decided to play a game, taking turns pressing these buttons. Anna makes the first turn. Each button can be pressed at most once, so at some point, one of the girls will not be able to make her turn.
The girl who cannot press a button loses. Determine who will win if both girls play optimally.
Input
The first line contains a single integer t� (1≤t≤1041≤�≤104) — the number of test cases.
Each test case consists of three integers a�, b�, and c� (1≤a,b,c≤1091≤�,�,�≤109) — the number of buttons that can only be pressed by Anna, the number of buttons that can only be pressed by Katie, and the number of buttons that can be pressed by either of them, respectively.
Output
For each test case, output First if Anna wins, or Second if Katie wins.
Example
input
Copy
5
1 1 1
9 3 3
1 2 3
6 6 9
2 2 8
output
Copy
First First Second First Second
Note
For the simplicity of the explanation, we will numerate the buttons by the numbers from 11 to a+b+c�+�+�: the first a� buttons can only be pressed by Anna, the next b� buttons can only be pressed by Katie, and the last c� buttons can be pressed by either of them.
In the first test case, Anna can press the 33-rd button on the first turn. Then Katie will press the 22-nd button (since it is the only possible turn for her). Then Anna will press the 11-st button. Katie won't have a button to press, so Anna will win.
In the second test case, Anna can press the first nine buttons in some order on her turns. No matter what buttons Katie will press, all the buttons from the 1010-th to the 1515-th will be pressed after 1212 turns. On the 1313-th turn, Anna will press one of the first nine buttons and Katie will not have a button to press on her turn. Thus, Anna will win.
In the third test case, the game can proceed as follows:
- On the 11-st turn Anna presses the 55-th button.
- On the 22-st turn Katie presses the 44-th button.
- On the 33-st turn Anna presses the 66-th button.
- On the 44-st turn Katie presses the 33-th button.
- On the 55-st turn Anna presses the 11-th button.
- On the 66-st turn Katie presses the 22-th button.
- Anna cannot make the turn, so Katie wins.
It can be shown that Katie can win no matter what moves Anna takes.文章来源:https://www.toymoban.com/news/detail-675855.html
解题说明:此题可以采用贪心算法,在每个人都选择最优的情况下,即两个人都先从c中去按按钮,此时需要判断c的奇偶和a与b的大小情况即可。文章来源地址https://www.toymoban.com/news/detail-675855.html
#include <stdio.h>
int main()
{
int n, a, b, c;
scanf("%d", &n);
while (n--)
{
scanf("%d%d%d", &a, &b, &c);
if (a > b)
{
printf("First\n");
}
else if (a == b && c % 2 != 0)
{
printf("First\n");
}
else
{
printf("Second\n");
}
}
return 0;
}
到了这里,关于A. Buttons的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!