杭电2013题

//蟠桃记
//思路:
//天数           吃掉个数        剩余个数   吃掉与剩余的关系
//0                0              F(0)
//1              F(0)/2+1         F(1) = F(0)/2-1
//2              F(1)/2+1         F(1) = F(1)/2-1
//..............................................
//n-2            F(n-3)/2+1       F(n-2) = F(n-3)/2-1
//n-1            F(n-2)/2+1       F(n-1) = F(n-2)/2-1
//               F(n-1) =1
 
#include <iostream>
using namespace std;
int main()
{
 int n;
 while(cin>>n)
 {
  int *p = new int[n];
  p[n-1] = 1;
  for(int i=n-1;i>0;i--)
  {
   p[i-1] = 2*(p[i]+1);
  }
  cout<<p[0]<<endl;
  delete []p;
 }
 return 0;
}

你可能感兴趣的:(杭电)