White Rectangles(hdu 1510)
来源:互联网 发布:网络英语哪家好 编辑:程序博客网 时间:2024/05/17 21:49
题目链接:
White Rectangles
分析:真的是神了,这种规律性的东西!谁想出来的!佩服!
. . . . 1 1 1 1
. . . . 2 2 2 2
. . . . 3 3 3 3
. . . . 4 4 4 4
以这种情况为例:一共有
1*4+2*4+3*4+4*4+(1)+(1+1)+(1+1+1)+(2)+(2+2)+(2+2+2)+(3)+(3+3)+(3+3+3)+(4)+(4+4)+(4+4+4)
真的是神了!
代码如下:
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>using namespace std;const int maxn=110;char A[maxn][maxn];int a[maxn][maxn];int main(){ int T; int sum; while (cin>>T){ getchar(); sum=0; memset(a,0,sizeof(a)); for(int i=0;i<T;i++){ gets(A[i]); int l=strlen(A[i]); for(int j=0;j<l;j++){ if(A[i][j]=='#') a[i][j]=0; else if(!i) a[i][j]=1; else a[i][j]=a[i-1][j]+1; sum+=a[i][j]; if(j){ int ans=a[i][j]; for(int x=j-1;x>=0;x--){ if(!a[i][x]) break; ans=min(ans,a[i][x]); sum+=ans; } } } } cout<<sum<<endl; } return 0;}
0 0
- hdu 1510 white rectangles
- White Rectangles(hdu 1510)
- ZOJ 2067 HDU 1510 White Rectangles
- 1510 White Rectangles
- White Rectangles
- ZOJ2067 White Rectangles
- zoj 2067 - White Rectangles
- ZOJ2067 White Rectangles 很好的DP递推啊
- hdu1510 White Rectangles(组合计数问题)
- HDU 3458 Rectangles Too!
- hdu 3458 Rectangles Too!
- hdu 3458 Rectangles Too!
- hdu 2056 Rectangles
- HDU 2056 Rectangles
- hdu 2056 Rectangles
- HDU 2056 Rectangles
- HDU 2056 rectangles
- HDU - 2056 Rectangles
- 算法研究之快速排序
- Winform 动态添加RadioButton、CheckBox 且任意分组
- Hadoop 之 注解
- 算法研究之左旋字符串
- [leetcode] Sort Colors
- White Rectangles(hdu 1510)
- poj1634
- 表达式生成满足条件的随机数据
- OC语言-----NSArray , NSMutableArray, NSNumber 基本用法
- 编程思想
- mysql的安装、C++访问mysql数据库、编码设置问题
- 网络编程时的字节顺序变换,地址变换
- [国学常识] 七情六欲八苦
- PDA接入ERP产品开发指南