当前位置: 首页 > 工具软件 > plane-game > 使用案例 >

F - Game on Plane Gym - 102058F (SG函数博弈)

湛玄裳
2023-12-01

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 TT test 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 Second if you need to move second so that you can win regardless of Koosaga's moves.

Example

Input

2
3
5

Output

First
Second

代码:


//Full of love and hope for life

#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <queue>
#define inf 0x3f3f3f3f
//https://paste.ubuntu.com/
//https://www.cnblogs.com/zzrturist/    //博客园
//https://blog.csdn.net/qq_44134712     //csdn

using namespace std;

typedef long long ll;
const ll maxn=1e7+10;

int sg[5010],s[5010];

void SG(){
    memset(sg,0,sizeof(sg));
    sg[1]=0;
    sg[2]=1;
    for(int i=3;i<=5000;i++){
        memset(s,0,sizeof(s));
        for(int j=0;j<i-2;j++){
            s[sg[j]^sg[i-j-2]]=1;
        }
        for(int j=0;j<=5000;j++){
            if(s[j]==0){
                sg[i]=j;
                break;
            }
        }
    }
}

int main(){
    SG();
    int a,b;
    cin >> a;
    while(a--){
        cin >> b;
        if(sg[b]){
            cout << "First" << endl;
        }
        else{
            cout << "Second" << endl;
        }
    }
    return 0;
}

 

 类似资料: