XDOJ1270 - Rectangle Counting
来源:互联网 发布:网络监控系统示意图 编辑:程序博客网 时间:2024/06/06 09:39
Description
The length and the width of the following figure are 2. How many rectangles are there in this figure?
There are 9 rectangles in this figure. They are 4 rectangles with each side 1*1, 2 rectangles with each side 1*2, 2 rectangles with each side 2*1 and 1 rectangle with each side 2*2.
Input
The input consists of several test cases.
The first line of the input contains a single integer T (0 < T ≤ 20), the number of test cases.
Then Followed by T lines, each line gives a test case which contains two positive integers N and M, which means the length and the width of the figure( 1≤ N, M ≤ 10 ).
The first line of the input contains a single integer T (0 < T ≤ 20), the number of test cases.
Then Followed by T lines, each line gives a test case which contains two positive integers N and M, which means the length and the width of the figure( 1≤ N, M ≤ 10 ).
Output
For each test case, output an integer indicating the number of rectangles in the figure.
Sample Input
2
1 1
2 2
1 1
2 2
Sample Output
1
9
9
解题 思路:
因为矩形的长和宽的选择没有相互关系,那么我们可以分别统计矩形的长和宽有多少种选择,然后由乘法原理得出矩形个数。以长的选择为例:网格长为N,则共有N+1个格点,于是长的选择方式为: C(N+1,2)=N*(N+1)/2 同理,宽的选择方式为: C(M+1,2)=M*(M+1)/2 矩形个数为N*(N+1)*M*(M+1)/4
0 0
- XDOJ1270 - Rectangle Counting
- Rectangle
- Rectangle
- Rectangle
- rectangle
- Rectangle
- Rectangle
- rectangle
- Rectangle
- Rectangle VC
- word rectangle
- draw rectangle
- Maximal Rectangle
- Maximal Rectangle
- GDI -Rectangle
- Maximal Rectangle
- Maximal Rectangle
- Maximal Rectangle
- DEDECMS织梦程序安装教程
- 播布客里小布老师的全部视频收集
- Android调用系统相机、自定义相机、处理大图片
- wamp5配置问题
- HNU 12946 Sort Me
- XDOJ1270 - Rectangle Counting
- Codeforces 463B Caisa and Pylons(水题)
- Linux下ARM开发环境搭建
- spring ioc原理(看完后大家可以自己写一个spring)
- Android 探秘对话框
- MDCC智能硬件征集关键词:智能家居、机器人、健康生活
- Text-overflow,text-align,text-transform,text-decoration,text-shadow,text-fill-color,text-stroke的属性
- wikioi 1043 双向dfs
- quick-cocos2dx在mac下打不开player