Microbial appreciation
topic
Suppose there are two microorganisms X and Y, X birth 3 minutes after divided once (double the number) intervals, Y 2 minutes divided once (double the number) intervals after birth.
A new-born X, half a minute after eating a Y, and, from the beginning, every minute to eat a Y.
Now give a constant n (n <= 60 and n is an integer) allows you to calculate the number y after n minutes.
Entry
The first input line n, x, y
10 2 20
Export
If y is the number of y <= 0 then outputs the output y n = 0 minutes
240
Thinking
The treated as a unit of half a minute, then split x: time% 6 == 0; y split: time% 4 == 0; x eat y: x% 2 == 1
Code
#include<iostream>
using namespace std;
int main()
{
int n,a,b;
cin>>n>>a>>b;
for(int i=1;i<=n;i++)
{
if(i%2==1) b=b-a;
if(b<0)
{
b=0;
break;
}
if(i%6==0) a *= 2;
if(i%4==0) b *= 2;
}
cout<<b;
return 0;
}