Skip to content

Instantly share code, notes, and snippets.

@simmucheng
Last active December 18, 2015 10:09
Show Gist options
  • Select an option

  • Save simmucheng/5766222 to your computer and use it in GitHub Desktop.

Select an option

Save simmucheng/5766222 to your computer and use it in GitHub Desktop.
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
int i,j,m,n;
scanf("%d",&n);
while(n--)
{
scanf("%d",&m);
for(i=1;i<=10;i++)
{
if(m%i==0)
m/=i;
else
{
if((m-1)%i==0)
{
m--;
m/=i;
}
else break;
}
//cout<<"m = "<<m<<endl;
if(m==1)break;
}
if(m==1)printf("Yes\n");
else printf("No\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment