fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int t;
  7. cin>>t;
  8. int a[t];
  9. for(int i=0;i<t;i++){
  10. int n;
  11. cin>>n;
  12. a[i]=n;
  13. }
  14. int max=INT_MIN;
  15. for(int i=0;i<t;i++)
  16. {
  17. if(a[i]>max)
  18. max=a[i];
  19. }
  20. long long int dp[max+1];
  21. dp[0]=1;
  22. dp[1]=1;
  23. for(int i=2;i<=max;i++)
  24. {
  25. dp[i]=(dp[i-1]*i)%1000000007;
  26.  
  27. }
  28. for(int i=0;i<t;i++)
  29. {
  30. long long int x=a[i];
  31. cout<<dp[x]<<"\n";
  32. }
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0s 5420KB
stdin
5
5
20
50
16
14
stdout
120
146326063
318608048
789741546
178290591