题意:求C(N,M)的约数个数.
分析:暴力分解质因数会TLE.所以先预处理.
记cnt[i,j]为i的阶乘中含第j个质数的个数(这样做要先筛素数).
然后C(N,M)=N!/(M!*(N-M)!)中含第i个质数的个数就是cnt[n,i]-cnt[m,i]-cnt[n-m,i].
这样就OK了(刷到了pascal的rank1).
code:
const MAX=440; var Prime:array[0..MAX] of longint; v:array[0..MAX] of boolean; cnt:array[0..max,0..100] of longint; size,n,m,i,j,num,tmp:longint; ans:qword; procedure GetPrime; begin size:=0; for i:=2 to MAX do begin if not v[i] then begin inc(size); prime[size]:=i; end; j:=1; while (j<=size)and(prime[j]*i<MAX) do begin v[i*prime[j]]:=true; if i mod prime[j]=0 then break; inc(j); end; end; end; begin GetPrime; for i:=1 to size do begin cnt[1,i]:=0; for j:=2 to max do begin tmp:=0; num:=j; while num mod prime[i]=0 do begin num:=num div prime[i]; inc(tmp); end; cnt[j,i]:=cnt[j-1,i]+tmp; end; end; while not seekeof do begin readln(n,m); ans:=1; for i:=1 to size do begin tmp:=cnt[n,i]-cnt[m,i]-cnt[n-m,i]; ans:=qword(ans)*qword(tmp+1); end; writeln(ans); end; end.