Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
429 B
6
Indexable
Never
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	map<ll,bool> check;
	ll t=1;
	int i=2;
	while (t<=(ll)pow(10,18))
	{
		t*=i;
		check[t]=true;
		i++;
	}
	int n;
	cin>>n;
	while (n--)
	{
	    ll x;
	    cin>>x;
		if (x==1) cout<<2;
		else
		if (check[x]) cout<<1;
		else cout<<0;
		cout<<'\n';
	}
	return 0;
}