StrongPrimePower
SRM 400 · 2008-05-01 · by ymatsu
Problem Statement
NOTE: This problem statement contains superscripts that may not display properly if viewed outside of the applet.
A number which can be represented as pq, where p is a prime number and q is an integer greater than 0, is called a prime power. If q is larger than 1, we call the number a strong prime power. You are given an integer n. If n is a strong prime power, return an
Constraints
- n will contain digits ('0' - '9') only.
- n will represent an integer between 2 and 10^18, inclusive.
- n will have no leading zeros.
"27"
Returns: {3, 3 }
27 = 33. This is a strong prime power.
"10"
Returns: { }
10 = 2 * 5. This is not a strong prime power.
"7"
Returns: { }
A prime number is not a strong prime power.
"1296"
Returns: { }
"576460752303423488"
Returns: {2, 59 }
Submissions are judged against all 217 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class StrongPrimePower with a public method vector<int> baseAndExponent(string n) · 217 test cases · 2 s / 256 MB per case