#QHD0000035. Bài phỏng vấn hôn nhân (The Marriage Interview)
Bài tập thuộc lộ trình
Mục lục đề ⌄
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 , the function returns without making further calls. If , it calls trib(n-1, back), trib(n-2, back), ..., trib(n-back, back), counting repeated calls separately.
Given and , compute the total number of function invocations starting from trib(n, back).
Input
One line contains and , 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): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
3 3
Output
Case 1: 7
Explanation
Every function invocation counts once. With , each base case takes one call. Thus the count for is , and the count for is . It is the first case, so the output starts with Case 1:.