DCP-231: Finding Biggest Power

Dev Skill archived problems can be discussed here.

DCP-231: Finding Biggest Power

by tariqiitju » Thu Feb 09, 2017 2:16 pm

i think something is very wrong with this problem.
http://paste.ubuntu.com/23959438/ this is a AC code. but look at this two cases:
n=10 p=15
n=10 p=25
10!=1x2x3x4x5x6x7x8x9x10=2^8 x 3^3 x 5^2 x 7^1
that is divisible with 15^2 and 25^1
both cases this code gives 0
i think correct approach for this problem needs to generate prime number till 10^9 , that is feasible and does not match the problem constrain.
then factorize p(such p=p1.p2.p3...pm , where each of them is mutually coprime) and taking min of each of pi's power in n!
 
Posts: 3
Joined: Thu Dec 15, 2016 9:01 pm

Who is online
Users browsing this forum: No registered users and 1 guest
cron