首页 > 代码库 > nyOJ基础题:另一种阶乘问题 如1!!+2!!+3!!

nyOJ基础题:另一种阶乘问题 如1!!+2!!+3!!

#include<stdio.h>int jCheng[21];//as you likevoid 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;}/*样例输入235样例输出523*/

 

nyOJ基础题:另一种阶乘问题 如1!!+2!!+3!!