Connection Status:
Competition Arena > BComputation
TCCC06 Round 2B · 2006-08-22 · by AdminBrett · Simple Math
Class Name: BComputation
Return Type: String
Method Name: getValue
Arg Types: (int, int)
Problem Statement

Problem Statement

You will be given B0, the first element of our sequence. The following equation must hold for all n > 0:
        0  =  B0 + n+1C1B1 + n+1C2B2 + ... + n+1CnBn 
Here aCb is the standard binomial coefficient (see the notes). Return the value Bpos in the form "p/q" (quotes for clarity) where p and q are integers with no extra leading zeros and no common factors (other than 1). The denominator q must always be positive. If the returned value is 0 then return "0/1".

Notes

  • aCb has value a!/(b!(a-b)!) where a! = a*(a-1)*...*2*1.

Constraints

  • B0 will be between -100 and 100, inclusive.
  • pos will be between 0 and 15, inclusive.
Examples
0)
1
0
Returns: "1/1"

Here we simply return B0.

1)
1
1
Returns: "-1/2"

Using the given formula, we can compute B1 = -B0/2C1.

2)
100
11
Returns: "0/1"
3)
1
4
Returns: "-1/30"
4)
1
5
Returns: "0/1"

Submissions are judged against all 72 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class BComputation with a public method string getValue(int B0, int pos) · 72 test cases · 2 s / 256 MB per case

Submitting as anonymous