A biologist is experimenting with DNA modification of bacterial colonies being grown in a linear array of culture dishes. By changing the DNA, he is able “program” the bacteria to respond to the population density of the neighboring dishes. Population is measured on a four point scale (from 0 to 3). The DNA information is represented as an array DNA, indexed from 0 to 9, of population density values and is interpreted as follows:
    • In any given culture dish, let K be the sum of that culture dish’s density and the densities of the dish immediately to the left and the dish immediately to the right. Then, by the next day, that
dish will have a population density of DNA[K].
    • The dish at the far left of the line is considered to have a left neighbor with population density 0.
    • The dish at the far right of the line is considered to have a right neighbor with population density 0.
    Now, clearly, some DNA programs cause all the bacteria to die off (e.g., [0,0,0,0,0,0,0,0,0,0]). Others result in immediate population explosions (e.g., [3,3,3,3,3,3,3,3,3,3]). The biologist is interested in how some of the less obvious intermediate DNA programs might behave.
    Write a program to simulate the culture growth in a line of 40 dishes, assuming that dish 20 starts with a population density of 1 and all other dishes start with a population density of 0.
Input
The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. This line is followed by a blank line, and there is also a blank line between two consecutive inputs.
    For each input set your program will read in the DNA program (10 integer values) on one line.
Output
For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.
    For each input set it should print the densities of the 40 dishes for each of the next 50 days. Each day’s printout should occupy one line of 40 characters. Each dish is represented by a single character on that line. Zero population densities are to be printed as the character ‘ ’. Population density 1 will be printed as the character ‘.’. Population density 2 will be printed as the character ‘x’. Population density 3 will be printed as the character ‘W’.
Note: Whe show only the first ten lines of output (the total number of lines must be 50) and the spaces have been replaced with the character ‘b’ for ease of reading. The actual output file will use the ASCII-space character, not ‘b’.
Sample Input
1
0 1 2 0 1 3 3 2 3 0
Sample Output
bbbbbbbbbbbbbbbbbbb.bbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbb…bbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbb.xbx.bbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbb.bb.bb.bbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbb…bbbbbbbbbbbbbbbb
bbbbbbbbbbbbbb.xbbbbbbbx.bbbbbbbbbbbbbbb
bbbbbbbbbbbbb.bbxbbbbbxbb.bbbbbbbbbbbbbb
bbbbbbbbbbbb…xxxbbbxxx…bbbbbbbbbbbbb
bbbbbbbbbbb.xb.WW.xbx.WW.bx.bbbbbbbbbbbb
bbbbbbbbbb.bbb.xxWb.bWxx.bbb.bbbbbbbbbbb

问题链接:UVA457 Linear Cellular Automata
问题简述:(略)
问题分析
    简单模拟题,不解释。
    需要注意数组大小。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA457 Linear Cellular Automata */#include <bits/stdc++.h>using namespace std;const int N = 10;
const int M = 40;
const int K = 50;
int a[M + 2], b[M + 2], dna[N];int main()
{int t;scanf("%d", &t);while(t--) {memset(a, 0, sizeof(a));memset(b, 0,sizeof(b));for(int i = 0; i < N; i++)scanf("%d", &dna[i]);a[M / 2] = b[M / 2] = 1;for(int i = 0; i < K; i++) {for(int j = 1; j <= M; j++) {if(a[j] == 0) putchar(' ');else if(a[j] == 1) putchar('.');else if(a[j] == 2) putchar('x');else if(a[j] == 3) putchar('W');b[j] = dna[a[j - 1] + a[j] + a[j + 1]];}putchar('\n');for(int j = 1; j <= M; j++)a[j] = b[j];}if(t) putchar('\n');}return 0;
}

UVA457 Linear Cellular Automata【模拟】相关推荐

  1. A.457 - Linear Cellular Automata

    2019独角兽企业重金招聘Python工程师标准>>> 第一天除了第20个培养皿密度为1外,其余全为0.  从第二天开始,第i个等于前一天的第i-1个+第i个+第i+1个的和所代表的 ...

  2. 元胞自动机(Cellular Automata)

    元胞自动机(Cellular Automata,简称CA,也有人译为细胞自动机.点格自动机.分子自动机或单元自动机).是一时间和空间都离散的动力系统.散布在规则格网 (Lattice Grid)中的每 ...

  3. 用matlab做元胞自动机预测,元胞自动机(Cellular Automata)与城市规划及其MATLAB实现——莆田市城市发展预测...

    前言 探索元胞自动机用于城市规划,是由于前不久在CSDN上看到相关案例后大开眼界,兴趣使然,想对家乡做一个城市发展预测,遂在巨人的肩膀上做一些探索与更正.文章末尾有这些案例的链接,感谢并致敬这些先行者 ...

  4. 元胞自动机(Cellular Automata)与城市规划及其MATLAB实现——莆田市城市发展预测

    github:https://github.com/Myoontyee/CA-city-planning-for-Putian-by-MATLAB 前言 探索元胞自动机用于城市规划,是由于前不久在CS ...

  5. A data-driven two-lane traffic flow model based on cellular automata

    A data-driven two-lane traffic flow model based on cellular automata 这是一篇发表在 Physica A 上的一篇论文.cellul ...

  6. POJ 3095 Linear Pachinko 字符串模拟

    http://poj.org/problem?id=3095 简单字符串模拟 Linear Pachinko Time Limit:1000MSMemory Limit:65536K Descript ...

  7. Competitive Programming 3题解

    题目一览: Competitive Programming 3: The New Lower Bound of Programming Contests(1) Competitive Programm ...

  8. AOAPC I: Beginning Algorithm Contests 题解

    AOAPC I: Beginning Algorithm Contests 题解 AOAPC I: Beginning Algorithm Contests (Rujia Liu) - Virtual ...

  9. 提取了下刘汝佳推荐的题号...

    今天闲来没事上uva oj提取了下刘汝佳推荐的acm题号,原始数据如下: Volume 0. Getting Started    10055 - Hashmat the Brave Warrior ...

最新文章

  1. HTTP缓存——304与200 from cache
  2. 2012到2020主要的CNN架构总结
  3. mysql中使用join exists in时该注意的问题
  4. 重学前端-学习笔记-JavaScript对象
  5. Linux下 数据文件 效验问题
  6. FFmpeg代码导读——HEVC在RTMP中的扩展
  7. 1005 Spell It Right (20 分)——13行代码Ac
  8. C#基础知识1-深入理解值类型和引用类型
  9. (转)如何入门 Python 爬虫
  10. 计算机组成原理袁春风知识点,计算机组成原理袁春风chap.pdf
  11. Excel:把数据生成曲线图
  12. source insight同步的时候崩溃_“我在国外,崩溃了一整年。”
  13. Apache Pulsar PMC 成员翟佳:开源和 Apache 社区是个带有魔法的宝库
  14. C语言实现对一维数组所有元素排序,然后将m1到m2之间的元素逆序
  15. 【wsl2】从头开始配置
  16. CAN 网络通信矩阵
  17. hive full join多表多关联键联合查询
  18. tushare实战LSTM实现黄金价格预测
  19. Tensorflow2.x 利用“GradientTape 梯度带”自动求梯度
  20. switch语句及三种循环语句

热门文章

  1. 2018-01-17
  2. arcpy.mapping常用四大件-MapsurroundElement
  3. 【java学习之路】(javaWeb【后端】篇)007.AjaxAxios
  4. 大数据学习之Hadoop任务输出到多个目录中
  5. sqoop从musql导入到hive中数据缺失
  6. php 提取字的首字母,PHP提取中文首字母_php技巧
  7. 比较经典的java程序_一些经典的java小程序代码,最好能复制后直接使用的 爱问知识人...
  8. scala中的伴生对象,
  9. plsql打开sql窗口快捷键_可以提升3倍开发效率的 Intellij IDEA快捷键大全汇总(2019)...
  10. 可以做服务器操作系统的是,可以做服务器操作系统