Logo
(追記) (追記ここまで)

14294번 - Partioning Number (Small) 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 512 MB48282163.636%

문제

Shekhu has N balls. She wants to distribute them among one or more buckets in a way that satisfies all of these constraints:

  1. The numbers of balls in the buckets must be in non-decreasing order when read from left to right.
  2. The leftmost bucket must be non-empty and the number of balls in the leftmost bucket must be divisible by D.
  3. The difference (in number of balls) between any two buckets (not just any two adjacent buckets) must be less than or equal to 2.

How many different ways are there for Shekhu to do this? Two ways are considered different if the lists of numbers of balls in buckets, reading left to right, are different.

입력

The first line of the input gives the number of test cases, T.

T test cases follow. Each test case consists of one line with two integers N and D, as described above.

Limits

  • 1 ≤ T ≤ 100.
  • 1 ≤ D ≤ 100.
  • 1 ≤ N ≤ 2000.

출력

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the answer, as described above.

제한

예제 입력 1

3
7 1
7 2
2 4

예제 출력 1

Case #1: 10
Case #2: 1
Case #3: 0

힌트

In sample case #1, the possible distributions are:

  • 1 1 1 1 1 1 1
  • 1 1 1 1 1 2
  • 1 1 1 1 3
  • 1 1 1 2 2
  • 1 2 2 2
  • 1 1 2 3
  • 1 3 3
  • 2 2 3
  • 3 4
  • 7

Note that 1 2 4 is not a valid distribution, since the difference between 1 and 4 is more than 2.

In sample case #2, the possible distributions are:

  • 2 2 3

3 4 is not possible, since the first term is not divisible by 2.

In sample case #3, no possible arrangement exists.

출처

Contest > Google > Google's Coding Competitions > Google APAC 2017 University Test > Round E APAC Test 2017 C1번

Contest > Google > Kick Start > Google Kick Start 2016 > Round E C1번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /