当前位置:网站首页>蓝桥杯 微生物增殖 C语言
蓝桥杯 微生物增殖 C语言
2022-07-06 11:38:00 【大菜彩】
微生物增殖
假设有两种微生物 X 和 Y
X出生后每隔3分钟分裂一次(数目加倍),Y出生后每隔2分钟分裂一次(数目加倍)。
一个新出生的X,半分钟之后吃掉1个Y,并且,从此开始,每隔1分钟吃1个Y。
现在已知有新出生的 X=10, Y=89,求60分钟后Y的数目。
如果X=10,Y=90呢?
本题的要求就是写出这两种初始条件下,60分钟后Y的数目。
以下程序实现了这一功能,请你补全空白处内容:
提示:Y分别会在0.5,1.5,2.5······时被吃,所以,把60分钟分成120份,则在除以2余数为1时,Y的数目减少X个
当X=10, Y=89,代码:
#include<stdio.h>
int main()
{
int x=10,y=89;
for(int t=1;t<=120;t++) //半分钟一个单位 60分钟为120个单位
{
if(t%2==1)
y=y-x; //因为X出生半分钟后就要吃Y,之后每1分钟要吃Y,所以永远都是奇数个半分钟的时候吃Y
if(t%4==0) //每两分钟翻倍
y=y*2;
if(t%6==0) //每三分钟翻倍
x=x*2;
}
printf("%d",y);
return 0;
}
运行结果为负数,故y=0。
当X=10, Y=90,运行结果:
边栏推荐
- Simple understanding of MySQL database
- CCNP Part 11 BGP (III) (essence)
- English topic assignment (25)
- R language uses rchisq function to generate random numbers that conform to Chi square distribution, and uses plot function to visualize random numbers that conform to Chi square distribution
- short i =1; I=i+1 and short i=1; Difference of i+=1
- 安装Mysql报错:Could not create or access the registry key needed for the...
- 如何自定义动漫头像?这6个免费精品在线卡通头像生成器,看一眼就怦然心动!
- About image reading and processing, etc
- 打家劫舍III[后序遍历与回溯+动态规划]
- Tensorflow and torch code verify whether CUDA is successfully installed
猜你喜欢
Systematic and detailed explanation of redis operation hash type data (with source code analysis and test results)
第五期个人能力认证考核通过名单公布
史上超级详细,想找工作的你还不看这份资料就晚了
黑馬--Redis篇
Sanmian ant financial successfully got the offer, and has experience in Android development agency recruitment and interview
MRO industrial products enterprise procurement system: how to refine procurement collaborative management? Industrial products enterprises that want to upgrade must see!
Actf 2022 came to a successful conclusion, and 0ops team won the second consecutive championship!!
谷粒商城--分布式高级篇P129~P339(完结)
五金机电行业供应商智慧管理平台解决方案:优化供应链管理,带动企业业绩增长
Leetcode 30. 串联所有单词的子串
随机推荐
Using clip path to draw irregular graphics
tensorflow和torch代码验证cuda是否安装成功
【翻译】Linkerd在欧洲和北美的采用率超过了Istio,2021年增长118%。
Carte de réflexion + code source + notes + projet, saut d'octets + jd + 360 + tri des questions d'entrevue Netease
Interview assault 63: how to remove duplication in MySQL?
【基础架构】Flink/Flink-CDC的部署和配置(MySQL / ES)
黑馬--Redis篇
How to access localhost:8000 by mobile phone
Documents to be used in IC design process
Problems encountered in using RT thread component fish
GCC【7】- 编译检查的是函数的声明,链接检查的是函数的定义bug
谷粒商城--分布式高级篇P129~P339(完结)
业务与应用同步发展:应用现代化的策略建议
Use of deg2rad and rad2deg functions in MATLAB
受益匪浅,安卓面试问题
Modulenotfounderror: no module named 'PIL' solution
[translation] micro survey of cloud native observation ability. Prometheus leads the trend, but there are still obstacles to understanding the health of the system
Meilu biological IPO was terminated: the annual revenue was 385million, and Chen Lin was the actual controller
Xingnuochi technology's IPO was terminated: it was planned to raise 350million yuan, with an annual revenue of 367million yuan
安装Mysql报错:Could not create or access the registry key needed for the...