算组合数中的素因子p的个数,基本同这题
http://www.cnblogs.com/autsky-jadek/p/6592194.html
#include<cstdio> using namespace std; typedef long long ll; int calc(int n,int p){ int res=0; ll t=p; while(t<=(ll)n){ res+=(n/(int)t); t*=(ll)p; } return res; } int T,n,m; int main(){ // freopen("b.in","r",stdin); scanf("%d",&T); for(;T;--T){ scanf("%d%d",&n,&m); printf("%d ",calc(2*n,m)-2*calc(n,m)); } return 0; }