fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <iostream>
  4. #include <string>
  5. #include <algorithm>
  6. #include <map>
  7. #include <vector>
  8. using namespace std;
  9. #define ll long long
  10. #define MAX 1000100
  11.  
  12. int n;
  13. ll mod;
  14.  
  15. void input(){
  16. scanf("%d", &n);
  17. }
  18.  
  19. ll mul(ll a,ll b){
  20. if(b == 0) return 0;
  21. if(b == 1) return a % mod;
  22. ll m = mul(a, b / 2);
  23. m = (m + m) % mod;
  24. if(b & 1) m = (m + a) % mod;
  25. return m;
  26. }
  27.  
  28. void process(){
  29. if(n >= 587117){
  30. printf("0");
  31. return;
  32. }
  33. ll ans = 1, gt = 1;
  34. mod = 109546051211;
  35. for(ll i = 1; i <= n; i++){
  36. gt = mul(gt, i);
  37. ans = mul(ans, gt);
  38. }
  39. printf("%lld", ans);
  40. }
  41.  
  42. int main(){
  43. //freopen("in.txt", "r", stdin);
  44. input();
  45. process();
  46. return 0;
  47. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
1