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 ...
随机推荐
- Linq 标准查询操作符三
本文介绍了LINQ标准查询操作符.没有这些操作符,LINQ就不会存在.本文为理解这些操作符的功能提供了很好的基础.了解它们将会很有帮助,因为LINQ的各种Provider都是基于这些操作符来完成各自丰 ...
- Qt根据类名创建对象(元对象反射)
在java语言中,可以使用getObject(String)函数,从类名直接构建新的对象. 而在C++中是没有这种机制的,Qt虽然提供了元对象机制,但只可以获取对象的类名,不能反向构建. 这个问题我在 ...
- 一大坨GoogleAPI的学习笔记之一(oAuth2.0)
官方文档地址:https://developers.google.com/accounts/docs/OAuth2InstalledApp 最近Ubuntu下VGA接口无端的不能用了,木有心情翻译了, ...
- 使用Promise规定来处理ajax请求的结果
ajax()返回结果是成功的,调用done()中的回调函数: 失败则调用fail()中的回调函数; always()的回调函数不管成功是否都会调用: 可以是使用then()函数代替done()和fai ...
- PHP PSR-4 Autoloader 自动加载(中文版)
Autoloader 关键词 “必须”("MUST").“一定不可/一定不能”("MUST NOT").“需要”("REQUIRED"). ...
- debian gnome 3插件
1.gnome 配置-安装插件 http://maxubuntu.blogspot.com/2012/09/debian-gnome3.html hunagqf|hunaqf2|hunaqf3 2.快 ...
- SQL Server 2008空间数据应用系列四:基础空间对象与函数应用
原文:SQL Server 2008空间数据应用系列四:基础空间对象与函数应用 友情提示,您阅读本篇博文的先决条件如下: 1.本文示例基于Microsoft SQL Server 2008 R2调测. ...
- 【转】内核编译时, 到底用make clean, make mrproper还是make distclean(转载)
原文网址:http://dongyulong.blog.51cto.com/1451604/449470 内核编译时, 到底用make clean, make mrproper还是make distc ...
- 三十三、Java图形化界面设计——布局管理器之null布局(空布局)
摘自http://blog.csdn.net/liujun13579/article/details/7774267 三十三.Java图形化界面设计--布局管理器之null布局(空布局) 一般容器都有 ...
- 【错误】:Could not open JDBC Connection for transaction; nested exception is: Communications link failure;The last packet sent successfully to the server was 1 milliseconds ago
# #错误日志 2016-11-10 16:19:20,834 ERROR [org.quartz.core.JobRunShell] - Job DEFAULT.jobtask threw an u ...