ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Game on Plane(博弈 SG)

2019-08-10 14:57:44  阅读:233  来源: 互联网

标签:sg move Koosaga Game Plane line first SG points


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 (1≤T≤50001≤T≤5000), the number of test cases. Each of the following TTtest cases is consisted of one line containing the integer NN (3≤N≤50003≤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 }

 

     

标签:sg,move,Koosaga,Game,Plane,line,first,SG,points
来源: https://www.cnblogs.com/0xiaoyu/p/11331574.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有