https://vjudge.net/contest/332560#problem/D
D - Decimal Gym - 102361D
Given a positive integer n, determine if 1n 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.

Example
Input
2
5
3
Output
No
Yes
Note
15=0.2, which is a finite decimal.

13=0.333⋯, which is an infinite decimal.

题解:题目是要判断1/n是不是无限小数,是就输出Yes否则No。

代码:

#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    int n, t;
    cin >> n;
    while(n--){
        cin >> t;

        if(t%5 == 0){
            do{
                t/=5;
            }while(t%5 == 0);
        }

        if(t%2 == 0){
            do{
                t/=2;
            }while(t%2 == 0);
        }

        if(t == 1){
            cout << "No" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }
    //system("pause");
    return 0;
}