1510 White Rectangles
来源:互联网 发布:淘宝客靠谱吗 编辑:程序博客网 时间:2024/06/05 16:49
White Rectangles
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 897 Accepted Submission(s): 453
Problem Description
You are given a chessboard made up of N squares by N squares with equal size. Some of the squares are colored black, and the others are colored white. Please write a program to calculate the number of rectangles which are completely made up of white squares.
Input
There are multiple test cases. Each test case begins with an integer N (1 <= N <= 100), the board size. The following N lines, each with N characters, have only two valid character values:
# - (sharp) representing a black square;
. - (point) representing a white square.
Process to the end of file.
# - (sharp) representing a black square;
. - (point) representing a white square.
Process to the end of file.
Output
For each test case in the input, your program must output the number of white rectangles, as shown in the sample output.
Sample Input
2.#..4..#.##.#.#...#.#
Sample Output
515
按鹏哥的代码来写的,虽然过了,但是感觉怪怪的
#include <iostream>#include<cstdio>using namespace std;int map[105][105];int judge(int x,int y1,int y2){ int t=1; for(int j=y1;j<=y2;j++) if(!map[x][j]) t=0; return t;}int main(){ int n; while(scanf("%d",&n)!=EOF) { char ch; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) { cin>>ch; if(ch=='.') map[i][j]=1; else map[i][j]=0; } for(int i=0;i<=n+1;i++) { map[n+1][i]=0; map[i][n+1]=0; } // cout<<map[1][2]<<endl; /*for(int i=1;i<=n+1;i++) { for(int j=1;j<=n+1;j++) cout<<map[i][j]<<" "; cout<<endl; }*/ int num=0; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) { if(map[i][j]==1) { int jj=j; while(map[i][jj]) { int ii=i; while(judge(ii,j,jj)) { num++; ii++; } jj++; } } } cout<<num<<endl; }return 0;}
0 0
- hdu 1510 white rectangles
- White Rectangles(hdu 1510)
- 1510 White Rectangles
- White Rectangles
- ZOJ 2067 HDU 1510 White Rectangles
- ZOJ2067 White Rectangles
- zoj 2067 - White Rectangles
- ZOJ2067 White Rectangles 很好的DP递推啊
- hdu1510 White Rectangles(组合计数问题)
- Rectangles
- Rectangles
- Rectangles
- Rectangles
- Rectangles
- White
- 1468 Rectangles
- Rectangles dp
- Packing Rectangles
- POJ 1163 The Triangle (简单 DP 数字的最大路线和)
- #1037 : 数字三角形(基础DP)
- win7下tomcat5.0.28安装版以服务方式启动报jsp不能解析的原因
- tag s:property must be empty, but is not错误原因
- springMVC中的视图解析器
- 1510 White Rectangles
- astyle整理代码格式
- 寻找最大数
- 很有用的PHP XML to Array函数
- 记一次调bug记录(15-4-17)
- linux系统-用户管理-概念及原理
- 软件环境报错处理
- 第六届蓝桥杯试题--生命之树 解题报告
- 1102 Constructing Roads