EpicPartition
SRM 781 · 2020-03-19 · by sinus_070
Problem Statement
Ramanujan loved partitions. And he also loved natural numbers. So, yay! He has a problem for you.
The set S consists of the first 6*N natural numbers. That is, S = {1, 2, ..., 6*N}. You have to partition S into three equally-large sets A, B, C. Additionally, this partition must be such that sum(C) = 2 * sum(A) = 2 * sum(B).
If there is no solution, return an empty
Constraints
- N will be between 1 and 100, inclusive.
1 Returns: ""
2 Returns: ""
3 Returns: ""
4 Returns: "aaabababbbbabbcccccccaac"
A = {1,2,3,4,6,18,19,22}. Sum(A) = 75. B = {5,7,8,9,10,11,12,13}. Sum(B) = 75 C = {14,15,16,17,20,21,23,24}. Sum(C) = 150 Satisfies size(A) = 2 * 4, size(B) = 2 * 4, size(C) = 2 * 4. And union of A,B,C = {1,2,3,...6*4}. And sum(C) = 2 * sum(A) = 2 * sum(B)
5 Returns: ""
Submissions are judged against all 100 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class EpicPartition with a public method string createPartition(int N) · 100 test cases · 2 s / 256 MB per case