题解:P15798 [GESP202603 五级] 有限不循环小数
思路
若
代码
#include<bits/stdc++.h>
using namespace std;
int l,r,ans;
bool check(int x){//判断是不是只有2和5两个质因数
while(x%2==0) x/=2;
while(x%5==0) x/=5;
return x==1;//最后如果不是1说明还有其他质因数
}
signed main(){
cin>>l>>r;
for(int i=l;i<=r;i++) ans+=check(i);//累计答案
cout<<ans;
return 0;
}