Blue Bridge Cup - 2012 C ++ A first set of questions: microbial enumeration value-added []

I, entitled

    Suppose there are two microorganisms X and Y

    X was born after a split every 3 minutes (double the number), Y 2 Fenzhong split time (the number doubled) after every birth.

    A new-born X, half a minute after eating a Y, and, from the beginning, every minute to eat a Y.

    Newborn now known X = 10, Y = 89, find the number Y after 60 minutes.

    If X = 10, Y = 90 it?

    The title is required to write both the initial condition, the number Y after 60 minutes.


    The results of the topic make you shocked yet? This is not a simple numbers game! The real biosphere have the same fragile nature! Maybe because you destroy the dog Y is the final straw that led to the extinction of the population Y!
    

    Please hold back the sadness, the answer in the "Answer .txt" Do not write here!

Second, the idea

Good half a minute process, we can in time integral x2, then every 6 minutes x corresponds to the number of doubling, doubling every 4 minutes number y, y-x is eaten every 2 minutes, while reducing the number of less than or equal to y 0 is over.

Third, the problem solution

#include <iostream>
using namespace std;

int main()
{
    int x=10;
    int y=90;
    int i;
    for (i=1;i<=120;i++)
    {
        if(y<=0)
        {
            y=0;
            break;
        }
        if(i%2==1)
        {
            y=y-x;
        }
        if(i%6==0)
        {
            x=x*2;
        }
        if(i%4==0)
        {
            y=y*2;
        }
    }
    cout << y << endl;
    return 0;
}

 

Fourth, the results

Published 57 original articles · won praise 9 · views 3592

Guess you like

Origin blog.csdn.net/Jayphone17/article/details/104224414