Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Count the Combination of Addition of Numbers in C

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 59
    Answer it

    Jojo, Lili, and Bibi is playing game about addition. Of course, addition is not a big problem for those who understand about how simple the addition is. But, they don’t want to add certain numbers, but they want to count how many combination of different numbers such that if they add all the numbers, they get N.

     

    They just want to find how many combination of (j, l, b) such that j + l + b = N.

     

    Format Input:

    Input consists of one integer T, the number of testcase, and followed by T lines of Ni which is N for i th testcase.

     

    Format Output:

    Output should be expressed in format ”Case #X: Y” - X is number of testcase and Y is one integer indicating the number of valid combination of (j, l, b) such that  j+l+b = Ni

     

    Sample Input

    2

    sample output

    6

    Explanation For Sample Test Case 1, The possible combinations for (j, l, n) are :

    • (0,0,2)

    • (0,1,1)

     • (0,2,0)

    • (1,0,1)

     • (1,1,0)

     • (2,0,0)

     the number of possible combination for (j, l, n) is 6

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: