nyOJ基础题:另一种阶乘问题 如1!!+2!!+3!!
#include<stdio.h> int jCheng[21];//as you like void generateSpecialJCheng(int input){ //!!阶乘存入第k个位置 for(int k = 1; k <= input; ++k){ int summary = 1; for(int s = 1; s <= k; s += 2){ summary *= s; } jCheng[k] = summary; } } int main(){ generateSpecialJCheng(20); int loop_rounds; while(~scanf("%d", &loop_rounds)){ while(loop_rounds--){ int t; unsigned long long total = 0; scanf("%d", &t); for(int i = 1; i <= t; i++){ total += jCheng[i]; } printf("%I64u\n", total); } } return 0; } /* 样例输入 2 3 5 样例输出 5 23 */
posted on 2014-12-18 17:12 True2009Fans 阅读(126) 评论(0) 编辑 收藏 举报