fork(5) download
  1. #include<stdio.h>
  2.  
  3. using namespace std;
  4. int main()
  5. {
  6. int t,a[160],n,i,j,temp,m,x;
  7. scanf("%d",&t);
  8. while(t--)
  9. {
  10. scanf("%d",&n);
  11. a[0]=1;
  12. m=1;
  13. temp = 0;
  14. for(i=1;i<=n;i++)
  15. {
  16. for(j=0;j<m;j++)
  17. {
  18. x = a[j]*i+temp;
  19. // cout<<a[j]<<"ä[j]"<<endl;
  20. a[j]=x%10;
  21. temp = x/10;
  22. //cout<<temp<<"temp1"<<endl;
  23. }
  24. while(temp!=0)
  25. {
  26. a[m]=temp%10;
  27. //cout<<a[m]<<"ä[m]"<<endl;
  28. temp = temp/10;
  29. //cout<<temp<<"temp2"<<endl;
  30. m++;
  31. }
  32. }
  33. for(i=m-1;i>=0;i--)
  34. printf("%d",a[i]);
  35. printf("\n");
  36. }
  37. return 0;
  38. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
Standard output is empty