HDU 1057 - A New Growth Industry
简单的模拟. 给定天数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的更多相关文章
- 【HDOJ】1057 A New Growth Industry
纯粹的模拟题目. #include <cstdio> #include <cstring> #include <cstdlib> #define MAXN 20 # ...
- HDU 1057 What Are You Talking About trie树 简单
http://acm.hdu.edu.cn/showproblem.php?pid=1075 题意 : 给一个单词表然后给一些单词,要求翻译单词表中有的单词,没有则直接输出原单词. 翻译文段部分get ...
- 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 ...
- 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 ...
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- 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 ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
- 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 ...
随机推荐
- 基于canvas图像处理的图片展示demo
图片展示网页往往色彩繁杂,当一个网页上有多张图片的时候用户的注意力就很不容易集中,而且会造成网站整个色调风格的不可把控. 能不能把所有的预览图变成灰度图片,等用户激活某张图片的时候再上色呢? 以前,唯 ...
- OpenCV——Sobel和拉普拉斯变换
Sobel变换和拉普拉斯变换都是高通滤波器. 什么是高通滤波器呢?就是保留图像的高频分量(变化剧烈的部分),抑制图像的低频分量(变化缓慢的部分).而图像变化剧烈的部分,往往反应的就是图像的边沿信息了. ...
- Js 导出Excel IE ActiveX控件
function ExportExcel() { var oXL = new ActiveXObject("Excel.Application"); //创建excel应用程序对象 ...
- js倒计时 重发 效果
<script type="text/javascript"> window.onload = function() { var wait = 60; function ...
- JS--switch 语句
说明:js中switch语句的语法风格 function convert(x){ switch(x) { case "string": document.write("s ...
- 对发给Application.Handle消息的三次执行(拦截)消息的过程
unit Main; interface uses SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, Forms ...
- SqlBulkCopy 类
1.SqlBulkCopy 简介 Microsoft SQL Server 提供一个称为 bcp 的流行的命令提示符实用工具,用于将数据从一个表移动到另一个表(表既可以在同一个服务器上,也可以在不同 ...
- 【Shell脚本】运行shell脚本文件的几种方法与区别
Shell脚本不同的运行方式会对当前Shell设置或者运行结果有所不同. 假设现在有一个脚本名为display_shell_script_args.sh,其内容如下: #!/home/pyf/bin/ ...
- 那些年的那些事CISC和RISC发展中的纠缠
本文来自http://www.cnbeta.com/articles/224544.htm ARM.ARM.ARM,没错ARM仿佛一夜之间就火了,平板.手机等领域随处可见它的影子,甚至已经有人预言未来 ...
- 学生管理系统(list)
学生管理系统:学习了一点文件指针的操作和链表操作,以前总想搞下子,刚好碰到同学要做这个,自己瞎搞了一通. 实现功能:数据添加,查找,删除,插入,修改只是在查找加几句就没写. #include < ...