HDOJ 2013_大二写
AC代码:
#include <iostream> #include <cstdio> using namespace std; int i=1; int hanshu(int n, int i) { int count; if(i == n) count = 1; else count = 2 * (hanshu(n, i+1) + 1); return count; } int main(void) { freopen("in.txt","r",stdin); int n; while(scanf("%d",&n) != EOF) { int sum; sum = hanshu(n,i); printf("%d\n",sum); } fclose(stdin); return 0; }