题目描述
Problem Description
Score: $ 250 $ points
E869120 has a long, vertically oriented calendar-like object.
One day, E869120 discovered that this calendar has the following regularity:
- The integer written in the $ i $th row from the top and $ j $th column from the left is $ 7i+j-7 $.
Also, E869120 has a $3 \times 3$ square frame.
So, E869120 decided to count the number of ways to place the square frame such that:
- The sum of the $ 9 $ numbers within the frame, when divided by $ 11 $, leaves a remainder of $ k $.
How many such placements of the frame satisfy the condition?
In this case, the calendar looks like the following table:
1st column 2nd column 3rd column 4th column 5th column 6th column 7th column 1st row 1 2 3 4 5 6 7 2nd row 8 9 10 11 12 13 14 3rd row 15 16 17 18 19 20 21 4th row 22 23 24 25 26 27 28 5th row 29 30 31 32 33 34 35 6th row 36 37 38 39 40 41 42 7th row 43 44 45 46 47 48 49
Here, $ (i, j) $ denotes the square at the $ i $th row from the top and $ j $th column from the left.
- When the top-left corner is $ (1, 5) $, $ 5+6+7+12+13+14+19+20+21=117 $, and the remainder when divided by $ 11 $ is $ 7 $.
- When the top-left corner is $ (3, 2) $, $ 16+17+18+23+24+25+30+31+32=216 $, and the remainder when divided by $ 11 $ is $ 7 $.
Only these two satisfy the condition.
100 8
Problem author: square1001
Input Format
Input is given from the standard input in the following format:
$n \quad k$
- The first line contains the number of rows $ n $ in the calendar and the number $ k $ that defines the condition for placing the square, separated by a space.
Output Format
- Output the number of ways to place the $3 \times 3$ square frame that satisfy the condition in one line.
- If no such placement is possible, output $ 0 $.
Sample Input and Output
Sample Input #1
7 7
Sample Output #1
2
```### Sample Input #2
6 0
### Sample Output #2
2
```### Sample Input #3
None
Sample Output #3
7
```### Sample Input #4
None
### Sample Output #4
45
```
Notes/Hints
Constraints
- $1 \le n \le 10^9$
- $0 \le k \le 10$
Subtasks
Subtask 1 \[ $ 150 $ points \]
- $1 \le n \le 100$
Subtask 2 \[ $ 100 $ points \]
- No additional constraints.
Sample Explanation 2
Only when the top-left corner is $ (1, 3) $ or $ (4, 4) $ does the condition hold.
Sample Explanation 3
The condition is satisfied when the top-left square is $ (2,2), (5,3), (8,4), (10,1), (11,5), (13,2), (16,3) $.
Sample Explanation 4
This input example satisfies Subtask 1.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分