PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#QHD0000035. Bài phỏng vấn hôn nhân (The Marriage Interview)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Bài phỏng vấn hôn nhân (The Marriage Interview)

The Marriage Interview

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

An interview uses the recursive function trib(n, back) to generate a tree of function calls. Every invocation, including an invocation that stops immediately, counts as one call.

If n≤1n\le1, the function returns without making further calls. If n>1n>1, it calls trib(n-1, back), trib(n-2, back), ..., trib(n-back, back), counting repeated calls separately.

Given nn and backback, compute the total number of function invocations starting from trib(n, back).

Input

One line contains nn and backback, the parameters of the initial call trib(n, back).

Output

Print Case 1: X, where X is the total number of calls to trib(n, back).

Subtasks

  • Subtask 1 (20 points): 0≤n≤150\le n\le 15; 0≤back≤600\le back\le 60.
  • Subtask 2 (30 points): 0≤n≤350\le n\le 35; 0≤back≤600\le back\le 60.
  • Subtask 3 (50 points): 0≤n≤600\le n\le 60; 0≤back≤600\le back\le 60.

Examples

Input

3 3

Output

Case 1: 7

Explanation

Every function invocation counts once. With back=3back=3, each base case n≤1n\le1 takes one call. Thus the count for n=2n=2 is 1+1+1+1=41+1+1+1=4, and the count for n=3n=3 is 1+4+1+1=71+4+1+1=7. It is the first case, so the output starts with Case 1:.