蟠桃记

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

   1 /*这这里用了递归的做法,思路比较简单,不用递归应该也可以做,但递归还是应该了解的*/
   2 #include "stdio.h"
   3 int tao(int day)
   4 {       
   5         if(day==1) return 1;
   6         else
   7                 return 2*tao(day-1)+2;
   8                 
   9 
  10 }
  11 void main()
  12 {
  13         int n;
  14         while(scanf("%d",&n)!=EOF)
  15                 printf("%d\n",tao(n));
  16 
  17 }.

hdu2013 (2008-06-02 12:31:01由czk编辑)

ch3n2k.com | Copyright (c) 2004-2020 czk.