阶乘因式分解(一) 给定两个数m,n,其中m是一个素数。 将n(0<=n<=10000)的阶乘分解质因数,求其中有多少个m。 输入第一行是一个整数s(0<s<=100),表示测试数据的组数 随后的s行, 每行有两个整数n,m。输出输出m的个数。

#include <stdio.h>
int main() {
int t,s,n,m;
scanf("%d",&s);
while(s--)
{
scanf("%d %d",&n,&m);
t=0;
for(;n>0;)
{
n=n/m;
t+=n;
}
printf("%d\n",t);
}

}

猜你喜欢

转载自www.cnblogs.com/Tristan-Adams/p/9066096.html
今日推荐