标签:
Description
Input
Output
Sample Input
Sample Output
1 #include <cstdio> 2 #include <cstring> 3 4 const int MAX = 24; 5 int arr[MAX][MAX]; 6 7 int main() 8 { 9 #ifdef CDZSC_OFFLINE 10 freopen("in.txt", "r", stdin); 11 freopen("out.txt", "w", stdout); 12 #endif 13 int t, n, sum, ans[MAX]; 14 memset(arr, 0, sizeof(arr)); 15 memset(ans, 0, sizeof(ans)); 16 for(int i = 0; i < MAX; i++) 17 { 18 arr[i][0] = 1; 19 for(int j = 1; j < i; j++) 20 { 21 arr[i][j] = arr[i - 1][j - 1] + arr[i - 1][j]; 22 } 23 arr[i][i] = 1; 24 } 25 for(int i = 1; i < MAX; i++) 26 { 27 sum = 0; 28 for(int j = 1; j <= i; j++) 29 { 30 sum += j * arr[i - 1][j - 1]; 31 } 32 ans[i] = sum; 33 } 34 scanf("%d", &t); 35 while(t--) 36 { 37 scanf("%d", &n); 38 printf("%d\n", ans[n]); 39 } 40 return 0; 41 }
标签:
原文地址:http://www.cnblogs.com/LiuACG/p/4246934.html