蓝桥杯第三届 微生物增殖

一、 微生物增殖

假设有两种微生物 和 Y

X出生后每隔3分钟分裂一次(数目加倍),Y出生后每隔2分钟分裂一次(数目加倍)。    一个新出生的X,半分钟之后吃掉1Y,并且,从此开始,每隔1分钟吃1Y

现在已知有新出生的 X=10, Y=89,求60分钟后Y的数目。

如果X=10Y=90  呢?

本题的要求就是写出这两种初始条件下,60分钟后Y的数目。

题目的结果令你震惊吗?这不是简单的数字游戏!真实的生物圈有着同样脆弱的性质!也许因为你消灭的那只 就是最终导致 种群灭绝的最后一根稻草!

请忍住悲伤,把答案写在“解答.txt”中,不要写在这里!

答案:和 94371840

小心y的负数溢出

源代码:

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<string.h>
#include<math.h>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX 0x3f3f3f3f
#define MIN -0x3f3f3f3f
#define PI 3.14159265358979323
#define N 10005
int main()
{
	int x, y;
	int i;
	x = 10;
	y = 90;
	for (i = 1; i <= 60; i++)
	{
		y -= x;
		if (i % 3 == 0)
			x *= 2;
		if (i % 2 == 0)
			y *= 2;
		if (y <= 0)
			y = 0;
	}
	printf("%d %d\n", x, y);
	return 0;
}


posted @ 2017-11-03 01:43  lemonsbiscuit  阅读(123)  评论(0编辑  收藏  举报