Another factorial problem time limit: theMs | Memory Limit:65535KB Difficulty:1
-
-
Describe
-
We all know the concept of factorial, give a simple example: 5! =1*2*3*4*5. Now we are introducing a new factorial concept that multiplies the original number by multiplying it by all the odd numbers multiplied by the I not greater than N for example: 5!! =1*3*5. Now understand the meaning of this factorial now!
Now your job is to find out 1!!. +2!! ... +n!! The correct value (N<=20)
-
-
Input
-
-
the first line enters a (a<=20), representing a group of test data
Next, enter an n for each row in line a.
-
-
Output
-
-
each row outputs an integer R representing 1!! +2!! ... +n!! The correct value
-
-
Sample input
-
-
235
-
-
Sample output
-
-
523
-
-
Source
-
-
[Zhang Jie] Original
#include <stdio.h>int a[22];int Main () {int i,j,n,test,sum;for (i=1;i<=20;i++) {a[i]=1;if (i&1) {for (j=1;j <=i;j+=2) A[i]*=j;} Else{for (j=1;j<i;j+=2) a[i]*=j;}} scanf ("%d", &test), while (test--) {scanf ("%d", &n), for (i=0,sum=0;i<=n;i++) sum+=a[i];p rintf ("%d\n", sum);} return 0;}
Another factorial problem (Nanyang Oj65)