Factorial factorization (i)

Source: Internet
Author: User

Describe

Given a two-digit m,n, where M is a prime number.

The factorial of N (0<=n<=10000) is decomposed factorization to find out how many m.

 
Input
The
first line is an integer s (0<s<=100) that represents the number of groups of test data
the following S-line, each line has two integer n,m.
Output
the number of output m.
Sample input
2100 516 2
Sample output
2415

1 ImportJava.util.Scanner;2 3  Public classMain {4      Public Static voidMain (string[] args) {5Scanner scanner=NewScanner (system.in);6         intT;7         inti;8         intJ;9         intN;Ten         intm; One         inttemp; A         intcount; -          -t=scanner.nextint (); the          for(i=0;i<t;i++){ -n=scanner.nextint (); -m=scanner.nextint (); -Count=0; +              -              for(j=1;j<=n;j++){ +temp=J; A                  while(true){ at                     if(temp%m==0){ -count++; -Temp/=m; -                     } -                     Else -                          Break; in                 } -             } to System.out.println (count); +         } -     }     the}

Factorial factorization (i)

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.