TheKingsFactorization
SRM 643 · 2014-08-25 · by Witaliy
Problem Statement
The King of Byteland likes integer factorization.
Your task is to help him factor the number N.
You will be given the
To make this task easier, the King has decided to give you a hint.
He already knows the correct factorization and he will tell you every second number in the correct return value.
More precisely, in addition to N you will be given a
Given N and primes, return the
Constraints
- N will be between 2 and 1,000,000,000,000,000,000 (10^18), inclusive.
- primes will contain the correct prime factors (as defined in the problem statement).
12
{2, 3}
Returns: {2, 2, 3 }
7
{7}
Returns: {7 }
1764
{2, 3, 7}
Returns: {2, 2, 3, 3, 7, 7 }
49
{7}
Returns: {7, 7 }
210
{2, 5}
Returns: {2, 3, 5, 7 }
Submissions are judged against all 208 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class TheKingsFactorization with a public method vector<long long> getVector(long long N, vector<long long> primes) · 208 test cases · 2 s / 256 MB per case