All we need to do is to find out a number nn, made of the last two digits of multiplication of given four numbers. Then If we divide nn by 25 then we will get which level it belongs to.

Lets say given numbers are aa, bb, cc, dd and m=a×b×c×dm=a \times b \times c \times d.

It is a fact that If we divide a number by 10 we get the last digit of that number as remainder. And If we divide a number by 100 we get a number consisting of the last two digits of that number as remainder. Thus, n=m%100n = m\%100 and floor[n/25]floor[n/25] is our desired answer.

One drawback of this solution is, we won't be able to store the result of multiplication with int (or even long long int) data type if the given numbers are large enough.

As we know from modular arithmetic, (a×b)%mod(a \times b)\%mod is the same as ((a%mod)×(b%mod))%mod((a\%mod) \times (b\%mod))\%mod.

Thus for this problem we can find the remainder of all four numbers after dividing by 100 and then multiply them. We again divide the result of multiplication to get the last two digits. Thus, we can avoid overflow in the multiplication step and then we determine the  level of Katana with the process mentioned above.

So the solution would be:

floor[(((a%100)(b%100)(c%100)(d%100))%100)/25]floor[(((a\%100)*(b\%100)*(c\%100)*(d\%100))\%100)/25]

Statistics

78% Solution Ratio
MursaleenEarliest, Apr '21
Shabab.2808Fastest, 0.0s
MursaleenLightest, 131 kB
bokaifShortest, 179B
Toph uses cookies. By continuing you agree to our Cookie Policy.