hdoj2013

写一下每天剩余的桃子数,再反向推一下公式,要注意:

剩下1个桃子是第n天准备吃的时候的桃子数,也就是第n-1天剩余的桃子数。

#include <iostream>
using namespace std;
int main()
{
    int n;
    while (cin >> n)
    {   
        n--;
        int s = 1;
        while(n--)
        {
            s = (s + 1 ) *2;
        }
        cout << s << endl;
            }
    return 0;
}

 

posted on 2017-09-08 11:00  平行线不会相交  阅读(107)  评论(0)    收藏  举报

导航