AtCoder Beginner Contest - Div Game
Author: Maggie Liu
Appears In
Time Complexity:
We can prime factorize as . To achieve the maximum number of operations, for each prime , we should first choose , then and so on.
As we prime factorize and find the exponent of each prime, we can decrement the exponent by , then , and so on, as long as the exponent stays nonnegative. Each time we decrement the exponent, we can add to the answer.
Join the USACO Forum!
Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!