#abc311e. E - Defect-free Squares
E - Defect-free Squares
Score : points
问题陈述
有一个 行和 列的网格。令 表示网格中从上数第 行、从左数第 列的方格。
网格中的每个方格要么是空洞,要么不是。恰好有 个空洞方格:。
当三元正整数组 满足以下条件时,以 为左上角、 为右下角的方格区域被称为无洞方块:
- 。
- 。
- 对于所有满足 的非负整数对 ,方格 都不是空洞。
请问网格中共有多少个无洞方块?
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There is a grid with rows and columns. Let denote the square at the -th row from the top and -th column from the left of the grid.
Each square of the grid is holed or not. There are exactly holed squares: .
When the triple of positive integers satisfies the following condition, the square region whose top-left corner is and whose bottom-right corner is is called a holeless square.
- .
- .
- For every pair of non-negative integers such that , square is not holed.
How many holeless squares are in the grid?
Constraints
- All are pairwise different.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the number of holeless squares.
Sample Input 1
2 3 1
2 3
Sample Output 1
6
There are six holeless squares, listed below. For the first five, , and the top-left and bottom-right corners are the same square.
- The square region whose top-left and bottom-right corners are .
- The square region whose top-left and bottom-right corners are .
- The square region whose top-left and bottom-right corners are .
- The square region whose top-left and bottom-right corners are .
- The square region whose top-left and bottom-right corners are .
- The square region whose top-left corner is and whose bottom-right corner is .
Sample Input 2
3 2 6
1 1
1 2
2 1
2 2
3 1
3 2
Sample Output 2
0
There may be no holeless square.
Sample Input 3
1 1 0
Sample Output 3
1
The whole grid may be a holeless square.
Sample Input 4
3000 3000 0
Sample Output 4
9004500500
update @ 2024/3/10 08:51:12