Given a positive integer n, determine if 1n1n is an infinite decimal in decimal base. If the answer is yes, print “Yes” in a single line, or print “No” if the answer is no.
Input
The first line contains one positive integer T (1 ≤ T ≤ 100), denoting the number of test cases.
For each test case:
Input a single line containing a positive integer n (1 ≤ n ≤ 100).
Output
Output T lines each contains a string “Yes” or “No”, denoting the answer to corresponding test case.
Sample Input
2
5
3
Sample Output
No
Yes
题目大意:
输入n,输出1/n是否为小数。
解题思路:
看n的质因子是否只有2 和5。
代码如下:
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
while(n%5==0){
n/=5;
}
while(n%2==0){
n/=2;
}
if(n==1) printf("No\n");
else printf("Yes\n");
}
return 0;
}