1340 - Story of Tomisu Ghost
Time Limit: 2 second(s)
Memory Limit: 32 MB
It is now 2150 AD and problem-setters are having a horrified time as the ghost of a problem-setter from the past, Mr. Tomisu, is frequently disturbing them. As always is the case in most common ghost stories, Mr. Tomisu has an unfulfilled dream: he had set 999 problems throughout his whole life but never had the leisure to set the 1000th problem. Being a ghost he cannot set problems now so he randomly asks problem-setters to complete one of his unfinished problems. One problem-setter tried to convince him saying that he should not regret as 999 is nowhere near 1024 (210) and he should not worry about power of 10 being an IT ghost. But the ghost slapped him hard after hearing this. So at last one problem setter decides to complete his problem:
"n! (factorial n) has at least t trailing zeroes in b based number system. Given the value of n and t, what is the maximum possible value of b?"
Input starts with an integer T (≤ 4000), denoting the number of test cases.
Each case contains two integers n (1 < n ≤ 105) and t (0 < t ≤ 1000). Both n and t will be given in decimal (base 10).
For each case, print the case number and the maximum possible value of b. Since b can be very large, so print b modulo 10000019. If such a base cannot be found then print -1 instead.
4
1000 1000
1000 2
10 8
4 2
Case 1: -1
Case 2: 5227616
Case 3: 2
Case 4: 2
Problem Setter: Shahriar Manzoor
Special Thanks: Jane Alam Jan, Md. Towhidul Islam Talukder
思路:很简单,只要将前面的数的阶乘素数分解,然后将每个因子的个数要求末尾0的个数然后答案*power(pi,ans/m);
其实就是把一个数写成k*d^m;中d的数值;
1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
手机扫一扫
移动阅读更方便
你可能感兴趣的文章