网格中矩形的个数
2015-07-28 21:29
204 查看
网格中矩形的个数
题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=84562#problem/N
题目:
Description
给你一个高为n ,宽为m列的网格,计算出这个网格中有多少个矩形,下图为高为2,宽为4的网格.
Input
第一行输入一个t, 表示有t组数据,然后每行输入n,m,分别表示网格的高和宽 ( n < 100 , m < 100).
Output
每行输出网格中有多少个矩形.
Sample Input
2
1 2
2 4
Sample Output
3
30
分析:找出规律即可
每个n*m的网格中矩形的个数为1加到n乘以1加到m。
题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=84562#problem/N
题目:
Description
给你一个高为n ,宽为m列的网格,计算出这个网格中有多少个矩形,下图为高为2,宽为4的网格.
Input
第一行输入一个t, 表示有t组数据,然后每行输入n,m,分别表示网格的高和宽 ( n < 100 , m < 100).
Output
每行输出网格中有多少个矩形.
Sample Input
2
1 2
2 4
Sample Output
3
30
分析:找出规律即可
每个n*m的网格中矩形的个数为1加到n乘以1加到m。
#include<iostream> using namespace std; int main() { int t,n,m,x,y; cin>>t; while(t--) { cin>>n>>m; x=(1+n)*n/2; y=(1+m)*m/2; cout<<x*y<<endl; } return 0; }
相关文章推荐
- (转)云计算 杂谈
- 暑假集训 第三周 STL I - Web Navigation网页导航
- 黑马程序员——高新技术---Java基础-IO流_File类,递归思想
- HDU 5317 RGCDQ
- 舞蹈链 - Sudoku
- iOS的文件管理——沙盒(sandbox)
- Lift Hopping (Uva 10801 最短路)
- Qt窗口中的一些小技术总结
- cocos2d小游戏---忍者吃西瓜
- 图结构练习——最小生成树
- 进制转换课后练习
- IOS switch-case知多少
- hdu 1712 ACboy needs your help (dp 分组背包)
- 自考路之策马扬鞭再奋蹄
- 简单实现标签切换效果
- 服务器升级linux内核
- 简说创业公司的技术选型,从BearyChat的开发说起
- Bootstrap简介
- 第一个 bat 文件
- ZOJ 3885 The Exchange of Items