MonsieurV's blog

By MonsieurV, history, 5 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

»
5 years ago, # |
  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].

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    but a[1], a[2], ... is float

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +3 Vote: I do not like it

      Can you give some sample test cases ?

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        ok N=10 out : 1.127016653792583 1.148715065833816 1.180378775426093 1.231912164917117 1.336027126931952 3.975950213098439

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it +3 Vote: I do not like it

          Ok , I will think about. I will reply when I get a solution.

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

Can you provide the problem link, please?