Блог пользователя into_the_world

Автор into_the_world, история, 23 месяца назад, По-английски

In yesterday's AtCoder Beginner Contest 280 I didn't able to solve D. Then I was looking for solution and after seeing this submission I was shocked. Can anyone tell me how the logic work for this problem submission?

D — Factorial and Multiple

Submission

Thanks.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
23 месяца назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

Here is an alternative approach. Suppose k is 1792. Convert 1792 into 2^8 * 7^1. It is clear that n needs to be at least 7 in order to cover the 7, but what is the n required to provide eight 2s? Let's count: 2 provides one 2. 4 provides two 2s. 6 provides one 2. 8 provides three 2s. Now we have (1+2+1+3 = 7) 2s. We still need one more. 10 provides one 2. Now we have eight 2s. This means n==10 is the max n needed. The other factor found earlier is n==7 but 7 is less than 10. So, the answer is 10.

Edit: Just realized OP was referring to a particular submission.