시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
20 초 (추가 시간 없음) | 1024 MB | 0 | 0 | 0 | 0.000% |
Pascal's triangle consists of an infinite number of rows of an increasing number of integers each, arranged in a triangular shape.
Let us define (r, k) as the k-th position from the left in the r-th row, with both r and k counted starting from 1. Then Pascal's triangle is defined by the following rules:
The first 5 rows of Pascal's triangle look like this:
In this problem, a Pascal walk is a sequence of s positions (r1, k1), (r2, k2), ..., (rs, ks) in Pascal's triangle that satisfy the following criteria:
Find any Pascal walk of S ≤ 500 positions such that the sum of the numbers in all of the positions it visits is equal to N. It is guaranteed that at least one such walk exists for every N.
The first line of the input gives the number of test cases, T. T test cases follow. Each consists of a single line containing a single integer N.
For each test case, first output a line containing Case #x:
, where x
is the test case number (starting from 1). Then, output your proposed Pascal walk of length S ≤ 500 using S additional lines. The i-th of these lines must be ri ki
where (ri, ki) is the i-th position in the walk. For example, the first line should be 1 1
since the first position for all valid walks is (1, 1). The sum of the numbers at the S positions of your proposed Pascal walk must be exactly N.
3 1 4 19
Case #1: 1 1 Case #2: 1 1 2 1 2 2 3 3 Case #3: 1 1 2 2 3 2 4 3 5 3 5 2 4 1 3 1
In Sample Case #1, only the starting position is needed.
In Sample Case #2, notice that although a shorter path exists, the path does not need to be of minimal length, as long as it uses no more than 500 positions.
The following image depicts our solution to Sample Case #3:
Contest > Google > Code Jam > Google Code Jam 2020 > Round 1A B번