标签:
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 878 Accepted Submission(s): 308
水题啊。。直接统计额。。
#include<iostream> #include<cstdio> #include<cstdlib> #include<cmath> #include<cstring> #include<string> #include<algorithm> using namespace std; int n,m,mp[2001][2001],x,y,sum[2001][2001]; char s[2001][2001]; int main() { while(scanf("%d%d",&n,&m)!=EOF) { if(n==0&&m==0) break; scanf("%d%d",&x,&y); memset(sum,0,sizeof(sum)); for(int i=1;i<=n;i++) { int cnt=0; scanf("%s",s[i]+1); for(int j=1;j<=m;j++) { if(s[i][j]==‘*‘) cnt++; sum[i][j]=sum[i-1][j]+cnt; } } int ans=0; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { if(i+x-1<=n&&j+y-1<=m) { int S=sum[i+x-1][j+y-1]-sum[i-1][j+y-1]-sum[i+x-1][j-1]+sum[i-1][j-1]; if(S==x*y) ans++; } if(i+y-1<=n&&j+x-1<=m&&x!=y) { int S=sum[i+y-1][j+x-1]-sum[i-1][j+x-1]-sum[i+y-1][j-1]+sum[i-1][j-1]; if(S==x*y) ans++; } } } printf("%d\n",ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/water-full/p/4488672.html