DCP-140: The Largest Factor Back to All Problems

Medium Math > Number Theory


Pizon and Redon are twin brothers. Both of them are quite genius and try to improve their capability by solving different types of mathematical problems specially the ones which are related to numbers and their factors. Just recently they found an interesting thing about factors of a factorial. Pizon first takes a pen and writes some uppercase English alphabets only from 'A' to 'I'. Then its Redon's turn. He represents the alphabets as one integer number where A = 0, B = 1 , ... I = 8. Suppose Pizon wrote "BA" , so Redon represents this as 10 which is an integer. Then they both give their friend Dadon a number which is always a prime and Dadon has to answer the highest power of that prime number that divides the factorials of Redon's integer. For BA , the integer is 10. And let the given number be 2. So Dadon has to print the highest power of 2 that divides 10! ( Ten Factorial ) . Input: ------ Input starts with an integer T (1<=20), denoting the number of test cases. Each case contains an string ( length <=8 ) and an integer ( which is prime & <= 10^7 ). Output: ------- The output is a single integer denoting the highest power. As the answer can be pretty large, Dadon is requested to print it modulo 1000000007. See sample for better understanding. Sample Input ------------ 2 BA 2 BAA 2 Sample Output ------------- Case 1: 8 Case 2: 97


Problem Setter:

Sifat Siddiqi Shishir

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 1.00
C++ 1.00
C++14 1.00
C# 3.00
Go 3.00
Java 3.00
JavaScript 3.00
Objective-C 3.00
Perl 3.00
PHP 3.00
Python 3.00
Python3 3.00
Ruby 3.00
VB.Net 3.00

Problem Stats

115/217

Solve/Submission

Ranking

# User Language Timing
01 Rajib_119 Cpp14 0.00s
02 BishalG Cpp14 0.00s
03 alhelal_cse Cpp14 0.00s
04 Roll_Number_27 Cpp14 0.00s
05 imranziad Cpp14 0.00s
06 Jakir_Hossain_Sust Cpp14 0.00s
07 nasif2587 Cpp14 0.00s
08 akazad_cse13_ruet Cpp14 0.00s
09 Puja1409 Cpp14 0.00s
10 Tanmoy_Datta Cpp14 0.00s
11 ssavi Cpp14 0.00s
12 KIRIN_36 Cpp14 0.00s
13 sayedgkm Cpp14 0.00s
14 shaft Cpp14 0.00s
15 subhashis_cse Cpp14 0.00s
16 codebreaker007 Cpp14 0.00s
17 haasib Cpp14 0.00s
18 Jisancse Cpp14 0.00s
19 tariqiitju Cpp14 0.00s
20 Protap_Ghose Cpp14 0.00s
21 froghramar Cpp14 0.00s
22 Mr_adnan Cpp14 0.00s
23 Masum_ice Cpp14 0.00s
24 Knight_King Cpp14 0.00s
25 shishir09 Cpp14 0.00s
26 adamantium Cpp14 0.00s
27 rayhan50001 Cpp14 0.00s
28 prantacse14 Cpp14 0.00s
29 rezaulhsagar Cpp14 0.00s
30 souravvv Cpp14 0.00s
31 SKL12 Cpp14 0.00s
32 feodorv C 0.00s
33 Ahb_arif Cpp14 0.00s
34 Sopto Cpp14 0.00s
35 onucsecu Cpp14 0.00s
36 sadia2427 Cpp14 0.00s
37 SakibAlamin Cpp14 0.00s
38 _dipu Cpp14 0.00s
39 alif_biswas Cpp14 0.00s
40 nurshuvo51 Cpp14 0.00s
41 alien_bd Cpp14 0.00s
42 aurko96 Cpp14 0.00s
43 Rakib05 Cpp 0.00s
44 Robbinb1993 Cpp 0.00s
45 ammasum Cpp14 0.01s
46 Key_logger Cpp14 0.01s
47 smriad Cpp 0.01s
48 hmtanbir Cpp14 0.01s
49 Bruteforcekid Cpp 0.01s
50 mahmud2690 Cpp 0.01s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support