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 ...
随机推荐
- (原)ubuntu上安装dlib
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5652791.html 参考网址: http://stackoverflow.com/questions ...
- git configuration
git的配置文件由section名和变量名组成: [user] name = abc emial = example.com []里面的user就是section名,section只能由字母,数字,- ...
- 设计模式 之 Organizing the Catalog 组织目录
Design patterns vary in their granularity and level of abstraction. Because thereare many design pat ...
- [置顶] highcharts封装使用总结
Highcharts 是一个用纯JavaScript编写的一个图表库, 能够很简单便捷的在web网站或是web应用程序添加有交互性的图表,并且免费提供给个人学习.个人网站和非商业用途使用.目前High ...
- gradle构建依赖
本地依赖 gradle 作为构建工具,能够很方便的使用本地jar包,以下为使用的代码块. dependencies { //单文件依赖 compile files('libs/android-supp ...
- js判断数组和对象
<script> var arr=new Array(); var obj={'1':2}; var num=11; function isType(obj){ if(obj instan ...
- Cows(poj 2481 树状数组)
Cows Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 15301 Accepted: 5095 Description ...
- ACM题目推荐(刘汝佳书上出现的一些题目)[非原创]
原地址:http://blog.csdn.net/hncqp/article/details/1758337 推荐一些题目,希望对参与ICPC竞赛的同学有所帮助. POJ上一些题目在http://16 ...
- linux环境下deb格式文件转换成rpm格式
以 alien_8.87.tar.gz 为例: 下载.安装 alien_8.87.tar.gz [root@shyn ~]# wget http://ftp.de.debian.org/debian/ ...
- lambda演算
先了解下相关的知识点(以下都只用先了解简单的概念,建议wiki): BNF范式,上下文无关文法,函数柯里化. lambda读书笔记演算: http://www.blogjava.net/wxb_nud ...