UVa 10780 Again Prime? No time. (number theory & factor decomposition)

Source: Internet
Author: User
Tags time limit

10780-again Prime? No time.

Time limit:3.000 seconds

Http://uva.onlinejudge.org/index.php? option=com_onlinejudge&itemid=8&category=467&page=show_problem&problem=17 21

The problem statement is very easy. Given a number n you have to determine the largest power of M., not necessarily prime, that divides n !.

Input

The input file consists of several test cases. The "the" the "the" number of cases to handle. The following lines are the cases each of which contains two integers m (1<m<5000) and N (0<n<100 the integers are separated by a space. There'll is no invalid cases given and There are not more. test Cases.

Output

For the "in" input, print the case number and separate lines. The result is either an integer if m divides n! Or a line "impossible to divide" (without the quotes). Check the sample input and output format.

Sample Input

2

2 10

2 100

Sample Output

Case 1:

8

Case 2:

97

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.