标签:des style blog http color java os io
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 120 Accepted Submission(s):
82
1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 using namespace std; 5 int n; 6 int main() 7 { 8 int n,m,map[200][200],i,j,t; 9 scanf("%d",&t); 10 while(t--) 11 { 12 scanf("%d%d",&n,&m); 13 memset(map,0,sizeof(map)); 14 for(i=1;i<=n;i++) 15 { 16 for(j=1;j<=m;j++) 17 { 18 map[i][j]=-1; 19 if((i%2==1)&&(j%2==1)) 20 map[i][j]=1; 21 if((i%2==0)&&(j%2==0)) 22 map[i][j]=1; 23 } 24 } 25 26 int a,b; 27 for(i=1;i<=n;i++) 28 for(j=1;j<=m;j++) 29 { 30 if(map[i][j]==1) 31 { 32 if(map[i-1][j]==-1&&i-1>=1) 33 { 34 map[i][j]*=2; 35 36 } 37 if(map[i][j-1]==-1&&j-1>=1) 38 { 39 map[i][j]*=2; 40 41 } 42 if(map[i+1][j]==-1&&i+1<=n) 43 { 44 map[i][j]*=2; 45 46 } 47 48 if(map[i][j+1]==-1&&j+1<=m) 49 { 50 map[i][j]*=2; 51 52 } 53 } 54 } 55 int ans=0; 56 for(i=1;i<=n;i++) 57 for(j=1;j<=m;j++) 58 { 59 if(map[i][j]!=-1) 60 ans+=map[i][j]; 61 } 62 63 printf("%d\n",ans); 64 65 } 66 return 0; 67 }
HDU-4925 Apple Tree,布布扣,bubuko.com
标签:des style blog http color java os io
原文地址:http://www.cnblogs.com/cancangood/p/3897896.html