阶乘因式分解(一)

阶乘因式分解(一)

时间限制:3000 ms  |  内存限制:65535 KB
难度:2
描述

给定两个数m,n,其中m是一个素数。

将n(0<=n<=10000)的阶乘分解质因数,求其中有多少个m。

输入
第一行是一个整数s(0<s<=100),表示测试数据的组数
随后的s行, 每行有两个整数n,m。
#include <stdio.h>
int main()
{
	int s;
	scanf("%d",&s);
	while(s--)
	{
		int n, m;
		scanf("%d%d", &n, &m);
		int count = 0;
		while(n)
		{
			count += n/m;
			n = n/m;
		}
		printf("%d\n", count);
	}

	return 0;
}

输出
输出m的个数。
样例输入
2
100 5
16 2
样例输出
24
15
题目转自南阳理工学院:http://acm.nyist.edu.cn/JudgeOnline/problemset.php 


个人代码(以下原创)



posted @ 2018-01-30 18:05  focus5679  阅读(132)  评论(0编辑  收藏  举报