MonsieurV's blog

By MonsieurV, history, 7 years ago, In English

for real numbers N(n<=2000), Find the longest real number array a[1], a[2], ..., a[m] such that the sum and product of that real number array is equal to N: a[1]+a[2]+...+a[m]=a[1].a[2]. ... . a[m] = N

here my code: http://ideone.com/2CsXul but it WA if n>=100

Sorry this is my first time writing blog

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

»
7 years ago, hide # |
 
Vote: I like it +13 Vote: I do not like it

I haven't looked at your code, but I think you can do this : First add all the prime factors of the number to the array, then add 1s to the array until the sum of the array is equal to N. Like for example , 84 the answer would be [2,2,3,7, and seventy 1s].

»
7 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Can you provide the problem link, please?