Game on Plane(博弈 SG)

You are given NN points on a plane. These points are precisely the set of vertices of some regular NN-gon. Koosaga, an extreme villain, is challenging you with a game using these points. You and Koosaga alternatively take turns, and in each turn, the player

  1. chooses two of the given points, then
  2. draws the line segment connecting the two chosen points.

Also, the newly drawn line segment must not intersect with any of the previously drawn line segments in the interior. It is possible for two segments to meet at their endpoints. If at any point of the game, there exists a convex polygon consisting of the drawn line segments, the game ends and the last player who made the move wins.

Given the integer NN, Koosaga is letting you decide who will move first. Your task is decide whether you need to move first or the second so that you can win regardless of Koosaga's moves.

Input

The input consists of many test cases. The first line contains an integer TT (1T50001≤T≤5000), the number of test cases. Each of the following TTtest cases is consisted of one line containing the integer NN (3N50003≤N≤5000).

Output

For each test case, print one line containing the string First if you need to move first or Secondif you need to move second so that you can win regardless of Koosaga's moves.

Example

Input
2
3
5
Output
First
Second
 1 #include <bits/stdc++.h>
 2 
 3 using namespace std;
 4 
 5 int sg[5005], vis[5005];
 6 
 7 void find_sg(int n)
 8 {
 9     int i, j;
10     memset(sg, 0, sizeof(sg));
11     for(i=1;i<=n;i++)
12     {
13         memset(vis, 0, sizeof(vis));
14         for(j=0;j<=i-2;j++)
15         {
16             vis[sg[j] ^ sg[i-j-2]] = 1;
17         }
18         for(j=0;j<=n;j++)
19         {
20             if(vis[j]==0)
21             {
22                 sg[i] = j;
23                 break;
24             }
25         }
26     }
27 }
28 
29 int main()
30 {
31     int t, n;
32     find_sg(5005);
33     cin >> t;
34     while(t--)
35     {
36         cin >> n;
37         if(sg[n]) cout << "First" << endl;
38         else cout << "Second" << endl;
39     }
40     return 0;
41 }

 

 
 
 

转载于:https://www.cnblogs.com/0xiaoyu/p/11331574.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值