简单的模拟.

给定天数n,给定D[0]~D[15]给定一个20*20的矩阵。
每个格子内有一个0~3的数字,表示细菌数。
每天,每个格子将加上D[k],k表示这个格子以及上下左右相邻格子的细菌之和(矩阵外算作0个,每格细菌个数不能超过3,不能低于0)。
问n天后的细菌情况。
 #include <iostream>
#include <cstdio>
using namespace std;
int t,n;
int d[];
int map[][],tmp[][];
char arr[]={'.','!','X','#'};
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=;i<;i++) scanf("%d",&d[i]);
for(int i=;i<;i++)
for(int j=;j<;j++)
scanf("%d",&map[i][j]);
int sum;
while(n--)
{
for(int i=;i<;i++)
for(int j=;j<;j++) tmp[i][j]=map[i][j];
for(int i=;i<;i++)
for(int j=;j<;j++)
{
sum=tmp[i][j];
if(i>) sum+=tmp[i-][j];
if(i<) sum+=tmp[i+][j];
if(j>) sum+=tmp[i][j-];
if(j<) sum+=tmp[i][j+];
map[i][j]+=d[sum];
map[i][j]= map[i][j]>? :map[i][j];
map[i][j]= map[i][j]<? :map[i][j];
}
}
for(int i=;i<;i++)
{
for(int j=;j<;j++)
cout<<arr[map[i][j]];
cout<<endl;
}
if(t) puts("");
}
}

HDU 1057 - A New Growth Industry的更多相关文章

  1. 【HDOJ】1057 A New Growth Industry

    纯粹的模拟题目. #include <cstdio> #include <cstring> #include <cstdlib> #define MAXN 20 # ...

  2. HDU 1057 What Are You Talking About trie树 简单

    http://acm.hdu.edu.cn/showproblem.php?pid=1075 题意 : 给一个单词表然后给一些单词,要求翻译单词表中有的单词,没有则直接输出原单词. 翻译文段部分get ...

  3. hdu 1057 (simulation, use sentinel to avoid boudary testing, use swap trick to avoid extra copy.) 分类: hdoj 2015-06-19 11:58 25人阅读 评论(0) 收藏

    use sentinel to avoid boudary testing, use swap trick to avoid extra copy. original version #include ...

  4. hdu 1057 A + B Again

    A + B Again Problem Description There must be many A + B problems in our HDOJ , now a new one is com ...

  5. POJ题目细究

    acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  102 ...

  6. 【转】POJ百道水题列表

    以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...

  7. Day 4 @ RSA Conference Asia Pacific & Japan 2016

    09.00 – 09.45 hrs Advanced Malware and the Cloud: The New Concept of 'Attack Fan-out' Krishna Naraya ...

  8. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

  9. HDU 1025 Constructing Roads In JGShining's Kingdom(二维LIS)

    Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65 ...

随机推荐

  1. PHP学习笔记二十八【抽象类】

    <?php //定义一个抽象类.主要用来被继承 //如果一个类继承了抽象类,则它必须实现该抽象类的所有抽象方法(除非它自己也是抽象类) // abstract class Animal{ pub ...

  2. c#窗体的传值方法

    了解了窗体的显示相关知识,接着总结一下窗体的传值方法:  .通过构造函数  特点:传值是单向的(不可以互相传值),实现简单 实现代码如下: 在窗体Form2中         int value1;  ...

  3. Webform用户控件

    用户控件一 用户控件二

  4. redis学习研究--Redis作者谈Redis应用场景

    毫无疑问,Redis开创了一种新的数据存储思路,使用Redis,我们不用在面对功能单调的数据库时,把精力放在如何把大象放进冰箱这样的问题上,而是利用Redis灵活多变的数据结构和数据操作,为不同的大象 ...

  5. struts2注解驱动 零配置

    一.配置web.xml<filter><filter-name>struts2</filter-name><filter-class>org.apach ...

  6. You and your research

    英文版http://www.cs.virginia.edu/~robins/YouAndYourResearch.html 视频版http://www.youtube.com/watch?v=a1zD ...

  7. 折腾gnome3.4

    1.平埔式窗口管理器shellshape 刚开始用都是登录时默认为gnome classic,主要是希望有任务栏,但是为了在这种模式,gnome扩展都没有用了. 而我又在使用shellshape -- ...

  8. html5视频小站

    本文目的 练习HTML5 学习css3新特性 学习和熟悉移动html基础开发,如触摸知识 网站特点 界面设计仿360影视移动网站 支持主流现代浏览器(注:IE9,chrome,firefox.safa ...

  9. bootstrap绿色大气后台模板下载[转]

    From:http://www.oschina.net/code/snippet_2364127_48176 1. [图片] 2. [文件] 素材火官网后台模板下载.rar ~ 4MB     下载( ...

  10. Python load json file with UTF-8 BOM header - Stack Overflow

    Python load json file with UTF-8 BOM header - Stack Overflow 3 down vote Since json.load(stream) use ...