当前位置:网站首页>蓝桥杯 微生物增殖 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,运行结果:

边栏推荐
- Pytorch common loss function
- MySQL information Schema Learning (i) - - General table
- 【翻译】云原生观察能力微调查。普罗米修斯引领潮流,但要了解系统的健康状况仍有障碍...
- Modulenotfounderror: no module named 'PIL' solution
- 10 schemes to ensure interface data security
- Excel 中VBA脚本的简单应用
- 黑馬--Redis篇
- C language daily practice - day 22: Zero foundation learning dynamic planning
- Countdown 2 days | live broadcast preview of Tencent cloud message queue data import platform
- map的使用(列表的数据赋值到表单,json逗号隔开显示赋值)
猜你喜欢
In depth analysis, Android interview real problem analysis is popular all over the network

Take a look at how cabloyjs workflow engine implements activiti boundary events

Reflection and illegalaccessexception exception during application

Computer network: sorting out common network interview questions (I)

Graffiti intelligence is listed on the dual main board in Hong Kong: market value of 11.2 billion Hong Kong, with an annual revenue of 300 million US dollars

MRO industrial products enterprise procurement system: how to refine procurement collaborative management? Industrial products enterprises that want to upgrade must see!

Black Horse - - Redis Chapter

MySQL information Schema Learning (i) - - General table

LeetCode-1279. 红绿灯路口

五金机电行业智能供应链管理系统解决方案:数智化供应链为传统产业“造新血”
随机推荐
MySQL information Schema Learning (i) - - General table
黑马--Redis篇
全套教学资料,阿里快手拼多多等7家大厂Android面试真题
终于可以一行代码也不用改了!ShardingSphere 原生驱动问世
LeetCode_ Double pointer_ Medium_ 61. rotating linked list
在解决了 2961 个用户反馈后,我做出了这样的改变...
How can my Haskell program or library find its version number- How can my Haskell program or library find its version number?
Countdown 2 days | live broadcast preview of Tencent cloud message queue data import platform
Actf 2022 came to a successful conclusion, and 0ops team won the second consecutive championship!!
Carte de réflexion + code source + notes + projet, saut d'octets + jd + 360 + tri des questions d'entrevue Netease
史上超级详细,想找工作的你还不看这份资料就晚了
LeetCode_双指针_中等_61. 旋转链表
[pytorch] yolov5 train your own data set
English topic assignment (25)
Mysql Information Schema 学习(二)--Innodb表
Pytorch common loss function
Excel 中VBA脚本的简单应用
Interface test tool - postman
Simple understanding of MySQL database
Test technology stack arrangement -- self cultivation of test development engineers