fork(4) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int a;
  7. cin>>a;
  8. while(a--) {
  9. int b, arr[200]={0};
  10. cin>>b;
  11. arr[0]=1;
  12. int i=1, m=1, index=0, temp=0, x;
  13. while(i<=b) {
  14. int k=m;
  15. index=0;
  16. while(k--) {
  17. x=arr[index]*i+temp;
  18. arr[index]=x%10, temp=x/10, index++;
  19. }
  20. while(temp!=0) {
  21. arr[index]=temp%10;
  22. temp=temp/10;
  23. index++, m++;
  24. }
  25. i++;
  26. }
  27. while(m--) cout<<arr[m];
  28. cout<<endl;
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0s 3344KB
stdin
4
1
2
5
3
stdout
1
2
120
6