UVA 457 - Linear Cellular Automata
2014-07-22 01:13
447 查看
题目链接:UVA457-LinearCellularAutomata
AbiologistisexperimentingwithDNAmodificationofbacterialcoloniesbeinggrowninalineararrayofculturedishes.BychangingtheDNA,heisable``program"thebacteriatorespondtothepopulationdensityoftheneighboringdishes.Populationismeasured
onafourpointscale(from0to3).TheDNAinformationisrepresentedasanarrayDNA,indexedfrom0to9,ofpopulationdensityvaluesandisinterpretedasfollows:
Inanygivenculturedish,letKbethesumofthatculturedish'sdensityandthedensitiesofthedishimmediatelytotheleftandthedishimmediatelytotheright.Then,bythenextday,thatdishwillhaveapopulation
densityofDNA[K].
Thedishatthefarleftofthelineisconsideredtohavealeftneighborwithpopulationdensity0.
Thedishatthefarrightofthelineisconsideredtohavearightneighborwithpopulationdensity0.
Now,clearly,someDNAprogramscauseallthebacteriatodieoff(e.g.,[0,0,0,0,0,0,0,0,0,0]).Othersresultinimmediatepopulationexplosions(e.g.,[3,3,3,3,3,3,3,3,3,3]).ThebiologistisinterestedinhowsomeofthelessobviousintermediateDNAprograms
mightbehave.
Writeaprogramtosimulatetheculturegrowthinalineof40dishes,assumingthatdish20startswithapopulationdensityof1andallotherdishesstartwithapopulationdensityof0.
Theinputbeginswithasinglepositiveintegeronalinebyitselfindicatingthenumberofthecasesfollowing,eachofthemasdescribedbelow.Thislineisfollowedbyablankline,andthereisalsoablanklinebetweentwoconsecutiveinputs.
ForeachinputsetyourprogramwillreadintheDNAprogram(10integervalues)ononeline.
Foreachtestcase,theoutputmustfollowthedescriptionbelow.Theoutputsoftwoconsecutivecaseswillbeseparatedbyablankline.
Foreachinputsetitshouldprintthedensitiesofthe40dishesforeachofthenext50days.Eachday'sprintoutshouldoccupyonelineof40characters.Eachdishisrepresentedbyasinglecharacteronthatline.Zeropopulationdensitiesaretobeprinted
asthecharacter`'.Populationdensity1willbeprintedasthecharacter`.'.Populationdensity2willbeprintedasthecharacter`x'.Populationdensity3willbeprintedasthecharacter`W'.
Note:Wheshowonlythefirsttenlinesofoutput(thetotalnumberoflinesmustbe50)andthespaceshavebeenreplacedwiththecharacter"b"foreaseofreading.TheactualoutputfilewillusetheASCII-spacecharacter,
not"b".
一个生物学家在做细菌的DNA转变试验,对象是在培养皿成直线排列生长的细菌群。通过改变DNA,他能够为细菌设定对旁边培养皿
的细菌密度的反应程式。细菌密度大小用0-3来衡量。DNA信息以细菌密度值的DNA数列表示,编号从0到9。说明如下:
在任一指定培养皿,K是该培养皿、该培养皿最靠近的左边的以及最靠近的右边的细菌密度的值之和为K,则第二天,该培养皿的细菌密度为
DNA[K].
假定一列培养皿中,最左边的培养皿的左边的培养皿的细菌密度为0,最右边的培养皿的右边的培养皿的细菌密度为0。
现在很清楚,一些DNA程式引起所有细菌死亡(如[0,0,0,0,0,0,0,0,0,0]),另一些则引起数量暴增(如
[3,3,3,3,3,3,3,3,3,3])。这个生物学家感兴趣的是其他一些没有那么明显的居中型的DNA程式会有什么结果。
编一程序模仿一列40个培养皿的细菌生长情况,假设20号培养皿开始时的细菌密度为1,而其他培养皿的细菌密度为0。
输入
在一行输入一个正整数,表示下面的个案的数目,每个个案如下所列。这一行后是一空行,而且两个连续的输入之间也有一空行。
每一组输入,你的程序会在一行上显示DNA程式(10个整数数值)
输出
每一个试验案例,输出必须与以下的描述一致。两个连续个案的输出之间有一空行。
每一组输入,应该打进以下50天中每天40个培养皿的细菌密度。每一天的输出应该占据一行40个字符。每一个培养皿由那一行的一
个字符表示。0密度以字符`'表示。1密度以`.'.表示。2密度以`x'表示。`3密度以`W'表示。
LinearCellularAutomata |
onafourpointscale(from0to3).TheDNAinformationisrepresentedasanarrayDNA,indexedfrom0to9,ofpopulationdensityvaluesandisinterpretedasfollows:
Inanygivenculturedish,letKbethesumofthatculturedish'sdensityandthedensitiesofthedishimmediatelytotheleftandthedishimmediatelytotheright.Then,bythenextday,thatdishwillhaveapopulation
densityofDNA[K].
Thedishatthefarleftofthelineisconsideredtohavealeftneighborwithpopulationdensity0.
Thedishatthefarrightofthelineisconsideredtohavearightneighborwithpopulationdensity0.
Now,clearly,someDNAprogramscauseallthebacteriatodieoff(e.g.,[0,0,0,0,0,0,0,0,0,0]).Othersresultinimmediatepopulationexplosions(e.g.,[3,3,3,3,3,3,3,3,3,3]).ThebiologistisinterestedinhowsomeofthelessobviousintermediateDNAprograms
mightbehave.
Writeaprogramtosimulatetheculturegrowthinalineof40dishes,assumingthatdish20startswithapopulationdensityof1andallotherdishesstartwithapopulationdensityof0.
Input
Theinputbeginswithasinglepositiveintegeronalinebyitselfindicatingthenumberofthecasesfollowing,eachofthemasdescribedbelow.Thislineisfollowedbyablankline,andthereisalsoablanklinebetweentwoconsecutiveinputs.ForeachinputsetyourprogramwillreadintheDNAprogram(10integervalues)ononeline.
Output
Foreachtestcase,theoutputmustfollowthedescriptionbelow.Theoutputsoftwoconsecutivecaseswillbeseparatedbyablankline.Foreachinputsetitshouldprintthedensitiesofthe40dishesforeachofthenext50days.Eachday'sprintoutshouldoccupyonelineof40characters.Eachdishisrepresentedbyasinglecharacteronthatline.Zeropopulationdensitiesaretobeprinted
asthecharacter`'.Populationdensity1willbeprintedasthecharacter`.'.Populationdensity2willbeprintedasthecharacter`x'.Populationdensity3willbeprintedasthecharacter`W'.
SampleInput
1 0120133230
SampleOutput
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:Wheshowonlythefirsttenlinesofoutput(thetotalnumberoflinesmustbe50)andthespaceshavebeenreplacedwiththecharacter"b"foreaseofreading.TheactualoutputfilewillusetheASCII-spacecharacter,
not"b".
题意
一个生物学家在做细菌的DNA转变试验,对象是在培养皿成直线排列生长的细菌群。通过改变DNA,他能够为细菌设定对旁边培养皿的细菌密度的反应程式。细菌密度大小用0-3来衡量。DNA信息以细菌密度值的DNA数列表示,编号从0到9。说明如下:
在任一指定培养皿,K是该培养皿、该培养皿最靠近的左边的以及最靠近的右边的细菌密度的值之和为K,则第二天,该培养皿的细菌密度为
DNA[K].
假定一列培养皿中,最左边的培养皿的左边的培养皿的细菌密度为0,最右边的培养皿的右边的培养皿的细菌密度为0。
现在很清楚,一些DNA程式引起所有细菌死亡(如[0,0,0,0,0,0,0,0,0,0]),另一些则引起数量暴增(如
[3,3,3,3,3,3,3,3,3,3])。这个生物学家感兴趣的是其他一些没有那么明显的居中型的DNA程式会有什么结果。
编一程序模仿一列40个培养皿的细菌生长情况,假设20号培养皿开始时的细菌密度为1,而其他培养皿的细菌密度为0。
输入
在一行输入一个正整数,表示下面的个案的数目,每个个案如下所列。这一行后是一空行,而且两个连续的输入之间也有一空行。
每一组输入,你的程序会在一行上显示DNA程式(10个整数数值)
输出
每一个试验案例,输出必须与以下的描述一致。两个连续个案的输出之间有一空行。
每一组输入,应该打进以下50天中每天40个培养皿的细菌密度。每一天的输出应该占据一行40个字符。每一个培养皿由那一行的一
个字符表示。0密度以字符`'表示。1密度以`.'.表示。2密度以`x'表示。`3密度以`W'表示。
代码
#include<iostream>
#include<cstring>
#include<cstdio>
usingnamespacestd;
intmain()
{
intt,dna[12],des[44],des2[44],k;
scanf("%d",&t);
while(t--)
{
for(inti=0;i<10;i++)
scanf("%d",&dna[i]);
memset(des,0,sizeof(des));
memset(des2,0,sizeof(des2));
des[20]=1;
for(inti=1;i<=50;i++)
{
for(intj=1;j<=40;j++)
{
if(des[j]==0)printf("");
elseif(des[j]==1)printf(".");
elseif(des[j]==2)printf("x");
elseif(des[j]==3)printf("W");
}
printf("\n");
des[0]=des[41]=0;
for(intj=1;j<=40;j++)
des2[j]=dna[des[j-1]+des[j]+des[j+1]];
memcpy(des,des2,sizeof(des2));
}
if(t!=0)printf("\n");
}
return0;
}
相关文章推荐
- UVA 457 - Linear Cellular Automata
- UVa 457 - Linear Cellular Automata
- 【UVA】【第0章】457 - Linear Cellular Automata
- UVA 457 Linear Cellular Automata
- uva457 - Linear Cellular Automata
- UVA457 - Linear Cellular Automata
- UVa 457 - Linear Cellular Automata
- UVa 457 Linear Cellular Automata (water ver.)
- UVa457 Linear Cellular Automata
- UVA-457-Linear Cellular Automata
- Uva - 457 - Linear Cellular Automata
- uva-457-Linear Cellular Automata
- UVa 457 - Linear Cellular Automata
- UVa 457 - Linear Cellular Automata
- UVA 457 - Linear Cellular Automata
- UVa_457 Linear Cellular Automata
- UVA 457 - Linear Cellular Automata
- UVA - 457 Linear Cellular Automata
- UVA OJ 457 - Linear Cellular Automata
- UVaOJ 457 - Linear Cellular Automata