Game|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
- chooses two of the given points, then
- draws the line segment connecting the two chosen points.
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).
【Game|Game on Plane(博弈 SG)】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 #include2 3 using namespace std; 4 5 int sg[5005], vis[5005]; 6 7 void find_sg(int n) 8 { 9int i, j; 10memset(sg, 0, sizeof(sg)); 11for(i=1; i<=n; i++) 12{ 13memset(vis, 0, sizeof(vis)); 14for(j=0; j<=i-2; j++) 15{ 16vis[sg[j] ^ sg[i-j-2]] = 1; 17} 18for(j=0; j<=n; j++) 19{ 20if(vis[j]==0) 21{ 22sg[i] = j; 23break; 24} 25} 26} 27 } 28 29 int main() 30 { 31int t, n; 32find_sg(5005); 33cin >> t; 34while(t--) 35{ 36cin >> n; 37if(sg[n]) cout << "First" << endl; 38else cout << "Second" << endl; 39} 40return 0; 41 }
转载于:https://www.cnblogs.com/0xiaoyu/p/11331574.html
推荐阅读
- 经济学人Water|经济学人Water Thirsty planet
- 游戏开发|pygame小游戏开发 - 冰雪英雄会
- 自助餐博弈论
- 足尖上的博弈
- PyGame每日一练——五子棋小游戏
- hdu|2016 Multi-University Training Contest 1 C Game(hdu 5725)
- POJ 1027 The Same Game 模拟题
- 比赛题解|2020 杭电多校9 1007 Game (平衡树)
- ZOJ-3447---Doraemon's Number Game (贪心+大数)
- 【组合计数】ARC061F Card Game for Three