ZOJ_1051_A New Growth Industry

OD图 arcgis曲线制作插件 od图曲线 路径图曲线制作插件 航线图曲线制作插件 在ArcGIS 10.2 中导入节点数据,打开插件,选择输入起始节点和目标节点的节点文件Point,以Name字段(地名)为连接线的起始字段和目标字段,(Input Table File)选择连接关系表格SDLine.csv,(Origin Column 和 Destination Column)为起始节点和目标节点,(Output Path)为输出路径,应选择.gdb数据库路径,否则容易报错,(Chord Coefficient)为连线的曲率,数值越大,曲率越高。运行环境:ArcGIS10.2。... 阅读详情
A New Growth Industry

Time Limit: 2 Seconds      Memory Limit: 65536 KB

A biologist experimenting with DNA modification of bacteria has found a way to make bacterial colonies sensitive to the 
surrounding population density. By changing the DNA, he is able to "program" the bacteria to respond to the varying densities in their immediate neighborhood. 

The culture dish is a square, divided into 400 smaller squares (20x20). Population in each small square is measured on a four point scale (from 0 to 3). The DNA information is represented as an array D, indexed from 0 to 15, of integer values and is interpreted as follows: 

In any given culture dish square, let K be the sum of that square's density and the densities of the four squares immediately to the left, right, above and below that square (squares outside the dish are considered to have density 0). Then, by the next day, that dish square's density will change by D[K] (which may be a positive, negative, or zero value). The total density cannot, however, exceed 3 nor drop below 0. 

Now, clearly, some DNA programs cause all the bacteria to die off (e.g., [-3, -3, ..., -3]). Others result in immediate population explosions (e.g., [3,3,3, ..., 3]), and others are just plain boring (e.g., [0, 0, ... 0]). The biologist is interested in how some of the less obvious DNA programs might behave. 

Write a program to simulate the culture growth, reading in the number of days to be simulated, the DNA rules, and the initial population densities of the dish. 


Input Format: 


Input to this program consists of three parts: 

1. The first line will contain a single integer denoting the number of days to be simulated. 

2. The second line will contain the DNA rule D as 16 integer values, ordered from D[0] to D[15], separated from one another by one or more blanks. Each integer will be in the range -3...3, inclusive. 

3. The remaining twenty lines of input will describe the initial population density in the culture dish. Each line describes one row of squares in the culture dish, and will contain 20 integers in the range 0...3, separated from one another by 1 or more blanks.


Output Format: 

The program will produce exactly 20 lines of output, describing the population densities in the culture dish at the end of the simulation. Each line represents a row of squares in the culture dish, and will consist of 20 characters, plus the usual end-of-line terminator. 

Each character will represent the population density at a single dish square, as follows:


No other characters may appear in the output. 


This problem contains multiple test cases!

The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.

The output format consists of N output blocks. There is a blank line between output blocks.


Sample Input:

1
2
0 1 1 1 2 1 0 -1 -1 -1 -2 -2 -3 -3 -3 -3
3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0


Sample Output:

##!.................
#!..................
!...................
....................
....................
....................
....................
.........!..........
........!#!.........
.......!#X#!........
........!#!.........
.........!..........
....................
....................
....................
....................
....................
....................
....................
....................

题意:这题还真考验英语能力。。反正我题目是看了N遍还看了别人的一些理解才理解题目。大概说明下意思,先输入n表示测试数据的组数。然后正式的输入数据开始了  然后输入一个数,在我的代码里面是days表示培养细菌的天数。再输入DNA信息,这里我用了数组d[16],然后是20*20的矩阵,用a[22][22]表示(我这么表示是免去了考虑边界溢出)。每个a[i][j]的值就是该位置培养皿的细菌密度,题目意思就是a[i][j]位置的培养皿的细菌密度受到周围4个位置的培养皿的影响,经过一天后,该位置培养皿的密度是本身原来密度加上4个边上的培养皿密度。最后计算完每个培养皿经i天后的密度,再用相应的符号代替培养皿密度的值即可

思路:这里注意几点。关键是题意的理解。以下说几个易错点再说思路。
1.一天后相应位置的密度是在原来自己的基础上加上四周的。
2.不要忘记进行第二组数据的测试前要对之前的变量再初始化(这个错误我找了2个小时多。。郁闷死)
3.必要变量重名
4.不要算好一个培养皿下一天的密度就是直接替换上去覆盖了原来的,会出错!(因为原来的密度会被周围的培养皿计算下一天的密度用到)
5.两组数据之间要有空行
6.最后一组数据输出结束后不用空行

我的思路是定义a[22][22]数组 初始化为0,然后根据题目的计算要求将下一天的密度记入到k[i][j]中,我定义的k[22][22]分别对应a[22][22]中的每个培养皿,然后一天的都计算完了,再将k[i][j]的值全部赋值给a[i][j].
其实理解了题意做起来还是很简单的.

Sample Program Here
#include<iostream>
using namespace std;
int main(){
   int a[22][22];
   char b[22][22];//保存替换字符后的值
   int days,n,i,j,k[22][22]; //days是天数,n是测试的组数,i,j是数组的参数,k是题目中的k
   int d[16];
   cin>>n;
   
   for(int t=0;t<n;t++){
	   cin>>days;
      //初始化
	   int a[22][22]={0};
	   char b[22][22]={0};

   //初始化DNA序列
	for(i=0;i<16;i++)  cin>>d[i];

   //初始化之后的20行
   for(i=1;i<21;i++)
	 for(j=1;j<21;j++)
	   cin>>a[i][j];
	   
   


  for(int day=0;day<days;day++){  //天数的循环
	//第d天的变化
   for(i=1;i<21;i++)
	 for(j=1;j<21;j++){
	    k[i][j]=a[i+1][j]+a[i][j+1]+a[i-1][j]+a[i][j-1]+a[i][j];//增加包括自己以内的上下左右的值,每个a[i][j]对应一个k值所以K也弄成二维数组
	 }


	 //要全部统计好再完成替换,直接算好替换会出错(因为利用的是新的值,原来的值被覆盖)
   for(i=1;i<21;i++)
	   for(j=1;j<21;j++){
	    a[i][j]+=d[k[i][j]]; //注意是by所以是再原有基础上增加
	      if(a[i][j]>3) a[i][j]=3;
		  else if(a[i][j]<0) a[i][j]=0;
	   }


	 
  }
	   
   

   //进行符号的替换
   for(i=0;i<22;i++)
	 for(j=0;j<22;j++){
	    if(a[i][j]==0) b[i][j]='.';
		else if(a[i][j]==1) b[i][j]='!';
		else if(a[i][j]==2) b[i][j]='X';
		else b[i][j]='#';
	
	 }


   //输出结果
	 for(i=1;i<21;i++){
	   for(j=1;j<21;j++){
		   cout<<b[i][j];
	   }
	   cout<<endl;
	 }
   
	if(t<n-1)
    cout<<endl;

   }//参数为t的for循环结束
   return 0;
}




        
飞牛NAS新增虚拟机功能,如果使用虚拟机网卡直通安装ikuai软路由(如何解决OVS网桥绑定失败以及打开ovs后无法访问飞牛nas等问题) 飞牛NAS新增虚拟机功能,如果使用虚拟机网卡直通安装ikuai软路由 阅读详情

相关推荐

医学图像可视化实战:ITK-SNAP与Python+SimpleITK双方案解析

本文深入解析了医学图像可视化的两大核心方案:ITK-SNAP与Python+SimpleITK。ITK-SNAP作为专业无损浏览器,是数据探索与分析的必备工具;而Python+SimpleITK方案则提供了自动化处理能力,但需注意将.nii.gz数据转换为JPG等格式时的信息损失。文章通过实战对比,为医学影像处理者提供了清晰的选择指南与避坑建议。

ol789012的博客 490

zoj1051--------A New Growth Industry 细菌~

把数组中的一个数,与其上下左右的四个数相加,得到的数值对应到DNA序列里面的对应数,把这个对应数加到原数组的对应位置, 然后超过三的为3,低于零的为0,处理后,即为一天的变化情况。 比如: 3 0 0             3 3 0             4 1 0            3 1 0 0 0 0  ——   3 0 0  ——   1 0 0 ——   1 0 0

Life is Float. 1361

pcb印刷电路缺陷检测----数据集准备

PKU-Market-PCB 印刷电路板 (PCB) 瑕疵数据集是一个公共合成 PCB 数据集,包含 1,386 张图像,具有 6 种缺陷(漏孔、鼠咬、开路、短路、杂散、杂铜),可用于图像检测、分类和配准任务。

qq_30190551的博客 4423

HDU 1057 模拟细菌的变化

模拟细菌变化

大咸鱼。。。 992

VTK实战笔记(1)在win11搭建VTK-9.4.2 + qt5.15.2 + VS2019_x64开发环境

Visual Studio 2019 + qt5.15.2 + vtk9.4.2

心向阳光,斗志昂扬! 973

AUTOSAR入门

一、AUTOSAR是什么 AUTOSAR组织自己的介绍是 AUTOSAR (AUTomotive Open System ARchitecture) is a worldwide development partnership of vehicle manufacturers, suppliers, service providers and companies from the automot...

天涯遍地是小草的博客 3万+

1051_A New Growth Industry

A biologist experimenting with DNA modification of bacteria has found a way to make bacterial colonies sensitive to the surrounding population density. By changing the DNA, he is able to "program"

李松雨的专栏 580

告别Qweb!用ReportBro在Odoo 13-19版本中5步搞定动态报表

本文介绍了如何在Odoo 13-19版本中使用ReportBro替代Qweb快速实现动态报表设计。通过5步集成指南,包括环境准备、前端集成、后端服务搭建等,展示了ReportBro在可视化设计、即时预览和多格式输出(PDF/XLSX)方面的优势,显著提升开发效率和报表灵活性。

mac99的博客 799

ZOJ Problem Set - 1051

ZOJ Problem Set - 1051 A New Growth Industry

My world 557

快速了解GPU分布通信技术:PCIe、NVLink与NVSwitch

PCIe(Peripheral Component Interconnect Express)是一种高速串行计算机扩展总线标准,广泛用于连接计算机的各种硬件设备。PCIe4.0是目前较为先进的版本,提供了高达64GB/s的带宽。InfiniBand是一种用于高性能计算的高速互连技术,通过交换机在节点之间直接创建一个专用的受保护通道。InfiniBand适配器通过PCIe接口连接到CPU,另一端通过InfiniBand网络端口连接到InfiniBand子网。

全世界的博客 7543

PCB工程师必看:别再搞错1078玻纤布的Dk了,手把手教你算等效介电常数

本文为PCB工程师提供了1078玻纤布等效介电常数(Dk)的详细计算指南,帮助解决高速设计中的信号完整性问题。通过解析玻纤布结构、混合介质理论和实战计算方法,指导工程师准确设置EDA工具参数,避免常见的Dk计算误区,提升设计精度和仿真准确性。

weixin_42546392的博客 398

zoj 1051 A New Growth Industry

zoj  这个就是一个傻逼题目。题目都根本没法看懂。看了人家的解题报告才弄懂什么意思。就是每个元素上下左右四边元素加上这个元素 , 这五个元素和在D数组里找对应码。然后这个对应码再加上当前位置元素判断是否大于3 或着小于0,大于3 取3 ,小于0取0。那么这个结果就是一天后每个块的种群密度。 /*============================================

舒哥的blog 835

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

Zoj1051 A New Growth Industry

Zoj1051 A New Growth Industry A biologist experimenting with DNA modification of bacteria has found a way to make bacterial colonies sensitive to the surrounding population density. By changing

星琳之梦的博客 497

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

ZOJ 1051 A New Growth Industry

A New Growth Industry Time Limit: 2 Seconds      Memory Limit: 65536 KB A biologist experimenting with DNA modification of bacteria has found a way to make bacterial colonies sensitive to the

胖子加油! 407

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

zoj1051 A New Growth Industry

//zoj1051 A New Growth Industry //Accepted 1051 C++ 00:00.00 388K #include #include #define MAXN 20

fairylan的专栏 1216

ZOJ1051 A New Growth Industry

这道题就是读懂题目太费劲了,非要扯到什么DNA上去,其实就是简单的数组处理,和上下左右的加加,然后查表把所得值加到当前项上来,若越界则处理下。Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include iostre

1766

zoj 1051 A New Growth Industry

正确代码: #include #include #include using namespace std;  int main() { int n; cin >> n; int day,today=1; vectorD(16); int rec[20][20],next[20][20],temp; string sign=".!X#"; while(n--

zeron_oo的专栏 434

ZOJ Problem Set - 1051 A New Growth Industry

A New Growth Industry Time Limit: 2 Seconds      Memory Limit: 65536 KB A biologist experimenting with DNA modification of bacteria has found a way to make bacterial colonies sensitive to the 

aaron的专栏 656

HDU 1051 A New Growth Industry

相同的代码,在zoj能ac,在hdu就runtime error 。。。 检查之后才发现,zoj中的数组开的太大了。。。 #include #include int main() {     int day,i,j,K,n;     int D[22],a[22][22],b[22][22];     scanf("%d",&n);     while(n--){

恋&空的专栏 754
上一篇: ZOJ_1049_I Think I Need a Houseboat
下一篇: ZOJ_1067_Color Me Less
wankaiming
博客等级 码龄15年 49粉丝 27原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值