# 3185. 双阶乘的质因数个数

### include

int zyzs(int a,int b){
int s = 0;
while(a % b == 0){
s += 1;
a /= b;
}
return s;
}
int main(){
int T;
scanf(“%d”,&T);
for (int i = 0 ; i < T ; i += 1){
int sum = 0;
printf(“case #%d:\n”,i);
int n , m ;
scanf(“%d%d”,&n,&m);
if (n % 2 == 1){
for (int j = 1 ; j <= n ; j += 2){
sum = sum + zyzs(j,m);
}
}else{
for ( int j = 2 ; j <= n ; j += 2 ){
sum = sum + zyzs(j,m);
}
}
printf(“%d\n”,sum);
}
}

### include

int main()
{
int N,M;
int i,j;
int m,count,k;
scanf(“%d”,&N);
for(M=0;M<N;M++){
scanf(“%d%d”,&i,&j);
count=0;
if(i%2==0){//偶数
for(m=2;m<=i;m+=2){
k=m;
while(k%j==0){
count++;
k=k/j;
}
}
}
else{//奇数
for(m=1;m<=i;m+=2){
k=m;
while(k%j==0){
count++;
k=k/j;
}
}
}
printf(“case #%d:\n”,M);
printf(“%d\n”,count);
}

}

### include

using namespace std;
int main() {
int t,count=0;
cin >> t;
while (t–) {
int n, m;
cin >> n >> m;
int ans = 0;
for(int i=1;i<=n;i++)
if (i % 2 == n % 2) {
int temp = i;
while (temp)
if (temp % m == 0) {
ans++;
temp /= m;
}
else
break;
}
cout << “case #” << count++ << “:\n”;
cout << ans << endl;
}
return 0;
}