Editorial for JDCC '16 Contest 4 P3 - Big Integer Factorization
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
If the prime factorization of a number is , then the prime factorization of is .
We just need to find the prime factorization of and multiply each power by when we print it. There is at most one prime factor greater than . Thus, we loop through all the whole numbers from to and check if it divides evenly. If so, then store how many times this number divides it. Divide the number by the factors (as many times as the power) while searching so that we only have prime factors in our list. After we are done searching all the numbers and if the number is not 1, then it means this is the greatest factor.
Time Complexity:
Comments