Problem 1001 gogog

wangeztian20 | 2016-05-12 17:03:12Author
#include <stdio.h> int f(int n, int* p) { if(n == 1) return 1; if(n == 2) return 2; p[n] = f(n-1, p) + (n-1)*f(n-2, p); return p[n]; } int main() { int ncase; int t=1; scanf("%d",&ncase); for(int i = 1; i <= ncase; ++i) { printf("sxx\n"); int n; scanf("%d",&n); int *p = new int[n]; printf("Case #%d:\n%d\n",t++,f(n, p)); printf("shh\n"); printf("sxxshh\n"); } return 0; }
wangeztian20 | 2016-05-12 17:03:55# 1
gogogo
#include <stdio.h> int f(int n, int* p) { if(n == 1) return 1; if(n == 2) return 2; p[n] = f(n-1, p) + (n-1)*f(n-2, p); return p[n]; } int main() { int ncase; int t=1; scanf("%d",&ncase); for(int i = 1; i <= ncase; ++i) { printf("sxx\n"); int n; scanf("%d",&n); int *p = new int[n]; printf("Case #%d:\n%d\n",t++,f(n, p)); printf("shh\n"); printf("sxxshh\n"); } return 0; }