2019 China Collegiate Programming Contest Qinhuangdao Onsite
传送门 D - Decimal 题意: 询问 \(\frac{1}{n}\) 是否为有限小数。 思路: 拆质因子,看是不是只包含2和5即可,否则除不尽。 Code #include <bits/stdc++.h> #define MP make_pair #define fi first #define se second #define sz(x) (int)(x).size() using namespace std; typedef long long ll; typedef pair<int, int> pii; const int N = 1e5 + 5; int t,n; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); #ifdef Local freopen("../input.in", "r", stdin); freopen("../output.out", "w", stdout); #endif cin>>t; while(t--){ cin>>n; while(n%2==0){ n/=2; } while(n%5==0){ n/=5; } if(n!=1)cout<<"Yes\n"; else cout<<"No\n"; } return 0; } E - Escape