hdu 2042 - 不容易系列之二
题意:(略)太长了
解法:找规律,发现A[i]=A[i-1]*2-2;
1: #include<stdlib.h>
2: #include<string.h>
3: #include<stdio.h>
4: #include<math.h>
5: #define N 31
6: int a[N]={3};
7: void init(){
8: int i;
9: for(i=1;i<N;i++){
10: a[i]=a[i-1]*2-2;//这个就是递推式
11: }
12: }
13: int main(){
14: int n,i;
15: init();
16: while(scanf("%d",&n)!=EOF){
17: while(n--){
18: int tmp;
19: scanf("%d",&tmp);
20: printf("%d\n",a[tmp]);
21: }
22: }
23: }