Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Fascination of ZERO

By mhiceiuk · Limits 1s, 512 MB

Sajeeb and Shoikot are two friends. Both are love mathematics. Sajeeb has a fascination with ZERO. They are discussing a math problem. MM is equal to AA to the power BB multiply CC to the power DD multiply E to the power FF. In mathematical equation:

M = A^B x C^D x E^F

Now, You are given six integers (AA, BB, CC, DD, EE, FF). You have to print the trailing zeros of MM.


The first line contains one integer tt (1t100001 \le t \le 10000). Each of the next tt lines contains six integers: AA, BB, CC, DD, EE and FF (0A,B,C,D,E,F10000000 \le A, B, C, D, E, F \le 1000000).


For each test case, print the case number as "Case X: " followed by the number of trailing zeros of MM.


2 3 4 2 5 1
2 1 6 2 8 2
Case 1: 1
Case 2: 0



93% Solution Ratio

steinumEarliest, 9M ago

jamil314Fastest, 0.0s

isratTLightest, 258 kB

steinumShortest, 539B


Login to submit

Toph uses cookies. By continuing you agree to our Cookie Policy.