Advertisement
Riz1Ahmed

My File.cpp

Jan 24th, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  3. #define FOR(i,l,r) for(i=l;i<=r;i++)
  4. #define ll long long int
  5. using namespace std;
  6. void Print(ll n) {printf("%lld\n",n);}
  7. const ll M=1e9+7,sz=1e7;
  8. int dx[]={0, 0,1,-1,1, 1,-1,-1};
  9. int dy[]={1,-1,0, 0,1,-1, 1,-1};
  10. int inner(int x,int n,int y,int m){
  11.     return -1<x&&x<n && -1<y&&y<m;}
  12. ll gcd(ll a,ll b) {return !(a%b)? b:gcd(b,a%b);}
  13. ll lcm(ll a,ll b) {return (a*b)/gcd(a,b);}
  14. ll PowerMod(ll a,ll n,ll M){
  15.     if (!n) return 1;
  16.     ll x=PowerMod(a,n/2,M);
  17.     x=(x*x)%M;
  18.     return (n&1)? (x*a)%M : x;
  19. }
  20. ll LogInt(ll n,ll base){
  21.     ll p=1,i;
  22.     for(i=1;; i++,p*=base)
  23.         if (p*base>n) break;
  24.     return i-1;
  25. }
  26. ll gcdExtended(ll a, ll b, ll &x, ll &y){
  27.     if (!a){x=0, y=1; return b;}
  28.     ll x1, y1;
  29.     ll gcd = gcdExtended(b%a, a, x1, y1);
  30.     x = y1-(b/a)*x1;
  31.     y = x1;
  32.     return gcd;
  33. }
  34. ll modInverse(ll a) {
  35.     ll x,y;///if a=0 not exist
  36.     ll g = gcdExtended(a,M,x,y);
  37.     if (g==1) return (x%M+M)%M;
  38.     printf("%d=ModInv not exist\n",a);
  39. }
  40. bool fl[sz+5];
  41. vector<int> prime;
  42. void sieve(){
  43.     for (int i=3; i*i<=sz; i+=2)
  44.         if (!fl[i])
  45.             for (int j=i+i; j<=sz; j+=i)
  46.                 fl[j]=1;
  47.     prime.push_back(2);
  48.     for (int i=3; i<=1e7; i+=2)
  49.         if (!fl[i]) prime.push_back(i);
  50. }
  51. int main(){
  52.     sieve();
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement