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 arrayDNA, indexed from 0 to 9, of population density values and is interpreted as follows:
- In any given culture dish, letKbe 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 ofDNA[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'.
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
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".
#define RUN #ifdef RUN #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include <string> #include <iostream> #include <sstream> #include <map> #include <set> #include <vector> #include <list> #include <cctype> #include <algorithm> #include <utility> #include <math.h> using namespace std; #define MAXN 105 int dna[10]; int buf[50][40]; void printout(){ for(int i=0; i<50; i++){ for(int j=0; j<40; j++){ switch(buf[i][j]){ case 0: printf(" "); break; case 1: printf("."); break; case 2: printf("x"); break; case 3: printf("W"); break; default: printf("?"); break; } } printf("\n"); } } void play(){ memset(buf, 0, sizeof(buf)); buf[0][19] = 1; for(int i=1; i<50; i++){ for(int j=0; j<40; j++){ int cnt = 0; for(int k=j-1; k<=j+1; k++){ if(k>=0 && k<=39){ cnt += buf[i-1][k]; } } buf[i][j] = dna[cnt]; } } printout(); } int main(){ #ifndef ONLINE_JUDGE freopen("457.in", "r", stdin); freopen("457.out", "w", stdout); #endif int n; scanf("%d", &n); getchar(); for(int i=0; i<n; i++){ getchar(); memset(dna, 0, sizeof(dna)); for(int j=0; j<10; j++){ scanf("%d", &dna[j]); } getchar(); play(); if(i != n-1){ printf("\n"); } } } #endif
相关推荐
The main objective of this paper is to increase the complexity by novel schemes of mixing (reversible cellular automata) RCA and (non-uniform reversible cellular automata) NRCA. We apply set of ...
LBM方法的其实来源,LBM是由格子气自动机发展而来,对于要深入研究LBM算法的研究者是学习的基本教材。
javascript-Cellular-Automata.rar
《Five Cellular Automata 7.70 英文版》作为一款专业的教育学习软件,为这一需求提供了强有力的工具。细胞自动机作为其核心,是一种被广泛用于模拟和理解自然界和社会现象的计算模型,它通过一组简单的规则就能展现...
python下载-cellular_automata.rar
Conference on Cellular Automata for Research and Industry, held at the University of Karlsruhe (Germany), 4 - 6 October, 2000. The continuation of and growing interest in research on Cellular Automata...
在本压缩包"python爱心代码高级python-cellular-automata.rar"中,我们关注的是一个特定的Python编程技术——细胞自动机(Cellular Automata)。细胞自动机是计算机科学中的一个重要概念,它是一种规则简单的离散...
数学建模-Cellular Automata in Matlab.zip
Quantum-dot cellular automata (QCA) device architecture is powerful to implement digital circuits in the nano-scale feature sizes. The layout of programmable logic array (PLA) structure in a single ...
在“Elementary-Cellular-Automata”项目中,可能包含以下关键知识点: 1. **Canvas API**:Canvas是HTML5中一个重要的绘图元素,允许开发者通过JavaScript在网页上绘制图形。在这个项目中,Canvas用于动态显示ECA...
本文档的标题“Calibration of stochastic cellular automata”(随机元胞自动机的参数校正)指出了研究的核心内容。元胞自动机(Cellular Automata, CA)是一种数学模型,用于模拟系统随时间变化的状态。该模型由多...
基于元胞自动机进行的室内人员疏散模拟代码
安装git clone https://github.com/elbecerrasoto/gym-cellular-automatapip install -e gym-cellular-automata基本用法随机政策import gymenv = gym . make ( 'gym_cellular_automata:forest-fire-v0' )obs = env ....
本文提出了一种利用量子点细胞自动机(Quantum-dot Cellular Automata,简称QCA)高效设计十进制全加器(Decimal Full Adder,简称DFA)的方法。随着互补金属氧化物半导体(Complementary Metal-Oxide Semiconductor...
Interactive 2D Cellular Automata in 3D is an interactive, 3-dimensional introduction to cellular automata (CA). Currently, the program allows the user to evolve a 100-cell CA grid step-by-step, ...
介绍了一种量子元胞自动机(QCA)可编程逻辑阵列结构,该结构可用于实现量子元胞自动机大规模可编程逻辑电路,采用QCADesigner仿真软件研究了元胞缺失、移位缺陷和未对准缺陷对可编程逻辑阵列单元逻辑功能的影响....
Basic Cellular Automata in Matlab
元胞自动机(Cellular Automata,简称CA)是一种离散模型,广泛应用于复杂系统的研究,包括物理、生物、社会科学等多个领域。在信息技术中,元胞自动机也因其并行计算能力和自组织特性,被用来解决各种问题,如图像...