FZU2164 Jason ' s problem

Source: Internet
Author: User

The topic is very understood, test instructions is for you n! and the K-suffix zero, allowing you to find the number of binary B that fits the criteria.
Suppose you've already asked for a n! decomposition, and then explained the first set of examples. n=10,k=2,n! The factorial can be expressed as 2^8*3^4*5^2*7, and then converted into this form (2^4*3^2*5) ^2*7, you can know how many kinds of feed to meet the conditions, that is, the combination of 2^4*3^2*5, there are 5*3*2 species, which must not meet the conditions, 2^0,2^1,2^2,3 ^0,3^1,5^0, there are 3*2*1 species, 30-6 equals 24 species. Why not meet the conditions, because if there is that kind of system will produce the extra 0.

The code is as follows

#include <cstdio>#include <cstring>using namespace STD;Const intMAXN =10000;typedef Long LongLL;ConstLL mod =1000000000+7;intT LL n,k;intPRI[MAXN],NUM[MAXN],VIS[MAXN];intCnt=1;intPrime () {memset(Vis,0,sizeofVIS); for(inti =2; i<10000; i++)if(!vis[i]) {pri[cnt++]=i; for(intJ=i+i; j<10000; J+=i) vis[j]=1; }}intSolveintNintP) {if(n<p)return 0;returnN/p+solve (n/p,p);}intMain () {prime ();//for (int i=1; i<=cnt; i++)//printf ("%d\n", Pri[i]);    scanf("%d", &t); while(t--) {memset(Num,0,sizeofNUM);scanf("%i64d%i64d", &n,&k); LL ans =1, ans1 =1;intI for(i=1; i<=cnt; i++) {inttt = n; Num[i]=solve (Tt,pri[i]);if(num[i]>=k) {LL temp = num[i]/k+1;                Ans = (ans*temp)%mod; LL Temp1 = temp-1;intjs=0; for(intj=1; j<=temp1; J + +) {if(num[i]/j!=k) js++; } ans1 = (ans1* (js+1))%mod;//printf ("%i64d\n", ans1);}Else  Break; }printf("%i64d\n", ((ans-ans1)%mod+mod)%mod); }}

FZU2164 Jason ' s problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.