NgJaBach

Modular Inverse

Oct 7th, 2021 (edited)
881
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | None
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4. typedef long long int ll;
  5. //#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
  6. #define pb push_back
  7. #define mp make_pair
  8. #define fi first
  9. #define se second
  10. #define gcd __gcd
  11. #define getl(s) getline(cin, s);
  12. #define setpre(x) fixed << setprecision(x)
  13. #define mset(a) memset(a, 0, sizeof(a))
  14. //#define endl '\n'
  15. const int N=10000000,M=1000000007;
  16. const ll INF=1e18+7;
  17. ll oneline_modulor_inverse(ll a,ll b){
  18.     return 1<a ? b-inverse(b%a,a)*b/a : 1;
  19. }
  20. ll binpow(ll a,ll b){
  21.     ll res=1;
  22.     while(b>0){
  23.         if(b&1) res=(res*a)%M;
  24.         a=(a*a)%M;
  25.         b>>=1;
  26.     }
  27.     return res;
  28. }
  29. vector<ll>inverse_array(int n,int m){
  30.     vector<ll>modu;
  31.     modu.pb(1);
  32.     modu.pb(1);
  33.     for(int i=2;i<=n;++i) modu.pb(modu[m%i]*(m-m/i)%m);
  34.     return modu;
  35. }
  36. int main(){
  37.     ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr);
  38. //    freopen(".inp","r",stdin);
  39. //    freopen(".out","w",stdout);
  40.    
  41.     return 0;
  42. }
  43. /*
  44. ==================================+
  45. INPUT:                            |
  46. ------------------------------    |
  47. 3
  48. 2 6
  49. ------------------------------    |
  50. ==================================+
  51. OUTPUT:                           |
  52. ------------------------------    |
  53.  
  54. ------------------------------    |
  55. ==================================+
  56. */
RAW Paste Data Copied