لینک‌های مفید برای شرکت در مسابقه:

در طول مسابقه، می‌توانید سؤالات خود را از قسمت «سؤال بپرسید» مطرح کنید.

D – Erfan and Minions


  • محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

Minions have been on this planet far longer than we have. They're all different. But they all share the same goal. To serve the most despicable master they could find. After thousands of rough years, finally they found the most despicable master in the world, “Erfan.aa”. They are very happy so they’re having a celebration. After dancing, singing and all of those “heavy rejections”, the time for lunch has come. The great Minion “Sir Kevin” is very creative. He and 88 other minions form a 3×33\times3 grid waiting for Erfan to bring them bananas. The grid is shown in the following picture. Each circle indicates a cell.

توضیح تصویر

Erfan has NN bananas. He will start from a cell on the grid and give a banana to the Minion on that cell and go to another cell, give another banana to the Minion on the new cell and so on... until he runs out of bananas. His movement among cells must obey the following rules:

  • The line connecting the current cell to the next cell should not pass through a cell with unfed Minion
  • Each Minion must be fed at most once.

Example:

If Erfan is on the cell 77 and The minion on the cell 44 is fed, he can move to the following cells: 1,2,5,6,81, 2, 5, 6, 8

Erfan is very curious. He wants to know how many ways exist to do this task. He’s now busy in the celebration, Can you help him?

ورودی🔗

The first line of input shows the number of test cases TT.

1T1001 \leq T \leq 100

Each of following TT lines contains two space separated integers SS and N,N, indicating start cell and number of bananas respectively.

1S,N9 1 \leq S, N \leq 9

خروجی🔗

For each test case, print a single line Case#<caseNumber> : <#PossibleWays>. For more clarifications see Sample Output.

مثال‌ها🔗

ورودی نمونه ۱🔗

4
1 2
5 2
2 1
3 3
Plain text

خروجی نمونه ۱🔗

Case#1 : 5
Case#2 : 8
Case#3 : 1
Case#4 : 31
Plain text

In the first test case:

There are 55 ways to do the task: {12},\{1 \to 2\}, {16},\{1 \to 6\}, {15},\{1 \to 5\}, {18},\{1 \to 8\}, {14}\{1 \to 4\}.

ارسال پاسخ برای این سؤال
در حال حاضر شما دسترسی ندارید.