Advertisement
albnayem

CC REDONE

May 12th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.29 KB | None | 0 0
  1. /*
  2. __Allahu Akbar__
  3. __All_praises_to_Allah__
  4. __Bismillahir_Rahmanir_Rahim__
  5.  
  6. Author: Abdullah Al Nayem
  7. Studying B.Sc in CSE at Leading University.
  8.  
  9. Practice, like you've never won. Perform, like you've never lost.
  10. Practice hard, play hard. Be hard to beat.
  11.  
  12. */
  13.  
  14. #include <bits/stdc++.h>
  15. #include <iostream>
  16. #include <cstdio>
  17. #include <algorithm>
  18. #include <math.h>
  19. #include <bitset>
  20. using namespace std;
  21.  
  22. #define MAX 1000007
  23. #define ll long long
  24. #define pb push_back
  25. #define mkp make_pair
  26. #define F first
  27. #define S second
  28. #define Sort_arr(arr,x) sort(arr,arr+x)
  29. #define Sortr_arr(arr,x) sort(arr, arr+n,greater<int>())
  30. #define SortS(str) sort(str.begin(), str.end())
  31. #define SortRS(str) sort(str.rbegin(), str.rend())
  32. #define arr_rev(n) sort(n.begin(), n.end(), greater<int>())
  33. #define gin(a) getline(cin,a)
  34. #define Sz(a) a.size()
  35. #define Ignore cin.ignore()
  36. #define sq(n) (n*n)
  37. #define cube(n) (n*n*n)
  38. #define min3(a, b, c) min(a, min(b, c))
  39. #define max3(a, b, c) max(a, max(b, c))
  40. #define YES cout << "YES" << endl
  41. #define NO cout << "NO" << endl
  42. #define pYES printf("YES\n")
  43. #define pNO printf("NO\n")
  44. #define bs binary_search
  45. #define lb lower_bound
  46. #define ub upper_bound
  47. #define all(a) a.begin(),a.end()
  48. #define Fast_read ios_base::sync_with_stdio(false);
  49.  
  50. //#define SIZE_N 32000
  51. //bitset <SIZE_N> bs;
  52. //ll int primes[SIZE_N+5];
  53. //vector<int> primes;
  54.  
  55. /*-----------------------Useful functions-----------------------*/
  56.  
  57. //ll int seive(){ll int i,j,total=0,val;for(i=2;i<=SIZE_N;i++) bs[i]=1;val=sqrt(SIZE_N)+1;for(i=2;i<val;i++)if(bs[i])for(j=i;j*i<=SIZE_N;j++)bs[i*j]=0;for(i=2;i<=SIZE_N;i++)if(bs[i])primes[total++]=i;return total;}
  58. //void Sseive() {bool isPrime[MAX];for (int i = 0; i < MAX; ++i) isPrime[i] = true;for (int i = 3; i * i <= MAX; i += 2) {if (isPrime[i]) {for (int j = i * i; j <= MAX; j += i) {isPrime[j] = false;}}}primes.push_back(2);for (int i = 3; i < MAX; i += 2) {if (isPrime[i]) primes.push_back(i);}}void segSieve (ll l, ll r) {bool isPrime[r-l+1];for (int i = 0; i < r - l + 1; ++i) isPrime[i] = true;if (l == 1) isPrime[0] = false;for (int i = 0; primes[i]*primes[i] <= r; ++i) {int currentPrime = primes[i];ll base = (l/currentPrime)*currentPrime;if (base < l) base += currentPrime;for (ll j = base; j <= r; j += currentPrime) {isPrime[j-l] = false;}if (base == currentPrime) isPrime[base-l] = true;}for (int i = 0; i < r - l + 1; ++i) {if (isPrime[i]) cout << (i+l) << endl;}puts("");}
  59. //ll int divisor_mcs(ll int N){ll int count=0,i;for (i=1;i<=sqrt(N);i++){if (N%i==0){count++;if (N/i!=i) count++;}}return count;}
  60. //int divisor(int N){int i,val,count,sum;val=sqrt(N)+1;sum=1;for(i=0;primes[i]<val;i++){if(N%primes[i]==0){count=0;while(N%primes[i]==0){N/=primes[i];count++;}sum*=(count+1);}}if(N>1)sum=sum*2;return sum;}
  61. //vector <int> primefactor(int n){int i;vector<int> primefact;for (i=2;i<=sqrt(n);i++){if (n%i==0){int count=0;while(n%i==0){n=n/i;count++;}while(count>0){primefact.pb(i);count--;}}}if (n!=1) primefact.pb(n);return primefact;}
  62. //vector <int> all_divisor(int n){int i;vector<int> all_div;for (i=2;i<=sqrt(n);i++){if (n%i==0) all_div.pb(i);if (n/i!=i && n%i==0) all_div.pb(n/i);}sort(all_div.begin(),all_div.end());return all_div;}
  63. //ll int GCD (ll int x, ll int y){if (x%y==0) return y; else return (GCD(y,x%y));}
  64. //ll int LCM (ll int a,ll int b) {return (a/GCD(a,b))*b;}
  65. //bool is_prime(ll int n){for (ll int i=2;i<=sqrt(n);i++){if (n%i==0) return false;}return true;}
  66.  
  67. /*------------------------------------------------------------------*/
  68.  
  69. vector <ll> vec;
  70.  
  71. void fact()
  72. {
  73. const unsigned int M = 1000000007;
  74.  
  75. unsigned long long f = 1;
  76. for (int i = 1; i <= 1000007; i++)
  77. f = (f*i) % M,vec.pb(f-1);
  78. ///cout<<f<<endl;
  79. ///vec.pb(f);
  80. }
  81.  
  82.  
  83. int main()
  84. {
  85. //seive();
  86. fact();
  87. //freopen("Nayem.txt", "r", stdin);
  88. Fast_read
  89.  
  90. ll test_case;
  91. cin>>test_case;
  92.  
  93. while (test_case--)
  94. {
  95. ll n;
  96. cin>>n;
  97. cout<<vec[n]<<endl;
  98. }
  99.  
  100.  
  101. return 0;
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement