[恢]hdu 2013

2011-12-12 05:10:11

地址:http://acm.hdu.edu.cn/showproblem.php?pid=2013

题意:中文。

思路:递推。设tab[n]表示第n天的桃子数。由题意知tab[n]/2-1 = tab[n-1],可得tab[n] = (tab[n-1]+1)*2。

代码:

# include <stdio.h>
# include <math.h>


int main ()
{
int i, tab[30] = {0, 1} ;
for (i = 2 ; i < 30 ; i++)
tab[i] = (tab[i-1]+1) * 2 ;
while (~scanf ("%d", &i))
printf ("%d\n", tab[i]) ;
return 0 ;
}



posted @ 2012-01-06 14:21  Seraph2012  阅读(112)  评论(0编辑  收藏  举报