fork(3) download
  1. #include<stdio.h>
  2. #include<math.h>
  3. int fac(int n){
  4. int c;
  5. short unsigned fact=1;
  6. for (c = 1; c <= n; c++)
  7. fact = fact * c;
  8. return fact;
  9. }
  10. int main(void){
  11. short unsigned T, temp, k=0, i, z;
  12. int N, ans[100001];
  13. scanf("%hu", &T);
  14. for(temp=0; temp<T; temp++){
  15. scanf("%d", &N);
  16. for(i=0; i<=N; i++)
  17. k=k+(fac(N+i)/((fac(N-i))*(fac(i))*(fac(i))));
  18. z=k%(N*N);
  19. ans[temp]=z;
  20. }
  21. for(temp=0; temp<T; temp++)
  22. printf("\n%d", ans[temp]);
  23. return 0;
  24. }
Success #stdin #stdout 0s 1904KB
stdin
Standard input is empty
stdout
Standard output is empty