Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

aboodmanna's blog

By aboodmanna, 9 years ago, In English

Hello everyone how i can sum a number (n) from array with at leaset specfic number (k) in JAVA .

like e.x ) n= 18 , k= 2

18 = 7 + 11 . array[2, 3, 5, 7, 11, 13, 17, 19, 23] ............................................... e.x) n = 11 , k= 3 11= 5 + 4 + 2 .

array[2, 3, 5, 4, 11, 13, 6, 19, 23]

  • Vote: I like it
  • -22
  • Vote: I do not like it

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

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

    sgtlaugh can you help me :)

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

      I'm sorry, I really can't comprehend what you're trying to say.

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

        how i can sum a number from an array

        check this :

        n=5

        array contain (1,4,2,2) :

        the element = 1+4 ==5

        how i can get these (1,4) ?

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

          You can use dynamic programming. Google for dynamic programming knapsack print solution.