#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
using namespace std;
typedef long long LL;
map<int,int> S;
int f(int n,int who)
{
if(n==1) return who;
if(S.find(n)!=S.end()) return S[n];
if(who==0)
{
if(n>1&&f(n-1,1)==1)
{
return S[n]= 1;
}
if(n>3&&f(n-3,1)==1)
{
return S[n]= 1;
}
if(n>7&&f(n-7,1)==1)
{
return S[n]= 1;
}
if(n>8&&f(n-8,1)==1)
{
return S[n]= 1;
}
return S[n]= 0;
}
else
{
if(n>1&&f(n-1,0)==0)
{
return S[n]= 0;
}
if(n>3&&f(n-3,0)==0)
{
return S[n]= 0;
}
if(n>7&&f(n-7,0)==0)
{
return S[n]= 0;
}
if(n>8&&f(n-8,0)==0)
{
return S[n]= 0;
}
return S[n]= 1;
}
}
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
cout<<f(n,0)<<endl;
}
}
/*
2 3 7 9
1 0 0 0*/
#include <iostream>#include <algorithm>#include <cstring>#include <map>using namespace std;type
最新推荐文章于 2023-04-21 00:03:21 发布