hdu 1057 A New Growth Industry

简介:

1057 A New Growth Industry

 

      简单模拟题,貌似uva上也有

      注意数据间要有空行

/*
author:jxy
lang:C/C++
university:China,Xidian University
**If you need to reprint,please indicate the source**
*/
#include <cstdio>
#include <cstring>
const char o[4]={'.','!','X','#'};
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
int day,now[20][20],next[20][20],change[16];
int main()
{
    int T,i,j,k,x,y,temp;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d",&day);
        for(i=0;i<16;i++)scanf("%d",&change[i]);
        for(i=0;i<20;i++)
          for(j=0;j<20;j++)
             scanf("%d",&now[i][j]);
        while(day--)
        {
            for(i=0;i<20;i++)
             for(j=0;j<20;j++)
             {
                temp=now[i][j];
                for(k=0;k<4;k++)
                {
                    x=i+dir[k][0];
                    y=j+dir[k][1];
                    if(x<0||x>=20||y<0||y>=20)continue;
                    temp+=now[x][y];
                }
                next[i][j]=now[i][j]+change[temp];
                if(next[i][j]<0)next[i][j]=0;
                if(next[i][j]>3)next[i][j]=3;
             }
            memcpy(now,next,sizeof(next));
        }
        for(i=0;i<20;i++,puts(""))
         for(j=0;j<20;j++)
             printf("%c",o[now[i][j]]);
        if(T)puts("");
    }
    return 0;
}


 

目录
相关文章
|
11月前
The Preliminary Contest for ICPC China Nanchang National Invitational A题 PERFECT NUMBER PROBLEM
The Preliminary Contest for ICPC China Nanchang National Invitational A题 PERFECT NUMBER PROBLEM
50 0
HDU-1057,A New Growth Industry(理解题意)
HDU-1057,A New Growth Industry(理解题意)
|
机器学习/深度学习 自然语言处理
|
Java
2017 Multi-University Training Contest - Team 9 1003&&HDU 6163 CSGO【计算几何】
CSGO Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 127    Accepted Submission(s): 20 Pro...
1384 0
[Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.5.9
(Schur's Theorem) If $A$ is positive, then $$\bex \per(A)\geq \det A. \eex$$   Solution. By Exercise I.
530 0
[Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.5.7
Prove that for any vectors $$\bex u_1,\cdots,u_k,\quad v_1,\cdots,v_k, \eex$$ we have $$\bex |\det(\sef{u_i,v_j})|^2 \leq \det\sex{\sef{u_i,u_j}}\cdot...
586 0