#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int x, y;
    while(cin >> x >> y)
    {
        vector<int> old; //存储每对的年龄
        int pairs = 0;
        int result = 0;

        for(int i = 1; i <= y; i++)
        {
            if(pairs == 0) //第一年就一对,到年末一岁
            {
                pairs++;
                old.push_back(1);
            }
            else
            {
                for(int j = 0; j < pairs; j++)
                {
                    old[j]++;
                    if(old[j] >= 2 && old[j] < x) //从2岁之后就生兔子了(但是最后一年不生),所以压入0
                        old.push_back(0);
                }

                while(!old.empty() && old[0] >= x) //看看前面的死没死,死了就去掉
                    old.erase(old.begin());
                if(old.size() > 10) { //大于10就让猎人带走两对
                    old.erase(old.begin());
                    old.erase(old.begin());
                }

                pairs = old.size();
            }
        }

        for(int i = 0; i < pairs; i++)
            result += 2 * old[i];
        cout <<result <<endl;
    }
    return 0;
}
这是我做的,能过100%