Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×

AndreiBalanici's blog

By AndreiBalanici, history, 6 years ago, In English

Partitioning a natural number n in order to get the maximum product sequence of its addends.Do anyone have informations about this problem?

  • Vote: I like it
  • +2
  • Vote: I do not like it

| Write comment?
»
6 years ago, hide # |
← Rev. 2  
Vote: I like it 0 Vote: I do not like it

Pseudocode (assume $$$n \geq 2$$$)

if (n % 3 == 0) {
  [print n/3 '3']
} else if (n % 3 == 1) {
  [print (n/3 - 1) '3' and a '4']
} else {
  [print n/3 '3' and a '2']
}