Skip to content

Anikcb/Programming

Repository files navigation

How to Boost your Rating!!🔥🔥

anik33122906anik33122906

Useful links

      https://www.youtube.com/channel/UCN_pqF_Y6IObpxapaQPHWZg
      https://blog.shahjalalshohag.com/topic-list/
      https://forthright48.com/p-cpps-101/
     https://github.com/me-shaon/bangla-programming-resources    



STL

Policy Based Data Structure(Ordered_Set) [1][2][3]

      - Policy Based Data Structure (Bangla) - Youtube[1]
      - C++ STL: Policy based data structures - Codeforces[2]
      - C++ STL: Policy based data structures, Part 2 - Codeforces[3]

Problems

Stars - Timus
https://acm.timus.ru/problem.aspx?space=1&num=1028
Solution
   ordered_set s;
   ll n;
   cin>>n;
   for(ll i=1;i<=n;i++)
   {
       ll a,b;
       cin>>a>>b;
       s.insert(make_pair(a,b));
       ll pos=s.order_of_key(make_pair(a,b));
       A[pos]++;
   }
   for(ll i=0;i<n;i++)cout<<A[i]<<endl;
      

Set, Unordered Set, Multiset [1][2][3]

      - SET, UNORDERED SET & MULTISET (Hindi) - Youtube[1]
      - Multiset in C++ STL - Youtube[2]
      - Multiset in C++ - GeeksforGeekss[3]

Problems

Mahesh and his lost array - CodeChef
   https://www.codechef.com/problems/ANUMLA
Solution
    Solve it!! 

Priority Queue [1][2]

      - std::priority_queue In C++ - Youtube[1]
      - C++ Priority Queue - Programiz[2]

Problems

No Name
   Priority Queue is very useful to solve Graph problems
Solution
    There is no solution right now!!


Math

Matrix Exponentiation [1][2]

      - Solving the Fibonacci Sequence with Matrix Exponentiation[1]
      - What is Fast Exponentiation?[2]

Problems

SUMMUL - SPOJ
Problem Link
https://www.spoj.com/problems/SUMMUL/
Solutions
Solution-1
    //#include <ext/pb_ds/assoc_container.hpp>
    //#include <ext/pb_ds/tree_policy.hpp>
    //#include<bits/stdc++.h>
    #include <iomanip>
    #include <iostream>
    #include <algorithm>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <string>
    #include <cmath>
    #include <vector>
    #include <set>
    #include <map>
    #include <unordered_set>
    #include <unordered_map>
    #include <stack>
    #include <queue>
    #include <deque>
    #include <iterator>
    #include <bitset>
    #include <assert.h>
    #include <new>
    #include <sstream>
    #include <time.h>


    //using    namespace __gnu_pbds;
    using namespace std;


    /*** Typedef ***/
    typedef long long ll;
    typedef unsigned long long ull;

    template<class T>
    inline T fastIn()
    {
        register char c = 0;
        register T a = 0;
        bool neg = false;

        while(c < 33) c = getchar();

        if(c == '-') neg = true;
        else a = c - '0';

        while(c = getchar(), c > 33)
            a = a * 10 + (c - '0');

        return (neg? -a : a);
    }

    /*** Input ***/
    #define sci1(a) scanf("%d",&a)
    #define sci2(a,b) scanf("%d %d",&a,&b)
    #define scln1(a) scanf("%lld",&a)
    #define scln2(a,b) scanf("%lld %lld",&a,&b)
    #define scln3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)


    /*** Output ***/
    #define pf1(a) printf("%d\n",a)
    #define pf2(a,b) printf("%d %d\n",a,b)
    #define pfln1(a) printf("%lld\n",a)
    #define pfln2(a,b) printf("%lld %lld\n",a,b)


    /*** Loops ***/
    #define foR0(num) for(ll i = 0; i < num; i++)
    #define foR1(num) for(ll i = 1; i <= num; i++)
    #define foRev(num) for(ll i = num - 1; i >= 0; i--)
    #define rep(i, x, n) for (ll i = x, _n = (n); i < _n; ++i)
    #define forIn(arr, num) for(ll i = 0; i < num; i++) cin>>arr[i];
    #define forIn1(arr, num) for(ll i = 1; i <= num; i++) cin>>arr[i];
    #define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
    #define apnt(arr, num) for(ll i = 0; i < num; i++) cout << arr[i] << (i + 1 < num ? ' ' : '\n');


    /*** Define Values ***/

    #define     ff                first
    #define     ss                second
    #define     re                return
    #define     MP                make_pair
    #define     pb                push_back
    #define     SZ(x)             ((ll) (x).size())


    #define     EPS               10E-10
    #define     mxx               100005
    #define     MOD               1000000007
    #define     iseq(a,b)         (fabs(a-b)<EPS)
    #define     PI                3.141592653589793238462643


    #define     Ceil(a,b)         (a+b-1)/b
    #define     gcd(a, b)         __gcd(a,b)
    #define     min3(a,b,c)       min(a,min(b,c))
    #define     max3(a,b,c)       max(a,max(b,c))
    #define     lcm(a, b)         ((a)/gcd(a,b))*(b)
    #define     min4(a,b,c,d)     min(d,min(a,min(b,c)))
    #define     max4(a,b,c,d)     max(d,max(a,max(b,c)))
    #define     input             freopen("input.txt","rt", stdin)
    #define     output            freopen("output.txt","wt", stdout)


    #define     all(v)            v.begin(),v.end()
    #define     mem(nam,val)      memset(nam, val, sizeof(nam))
    #define     ps(x,y)           fixed<<setprecision(y)<<x
    #define     for2D0(n,m)       for(ll i=0;i<n;i++)for(ll j=0;j<m;j++)
    #define     for2D1(n,m)       for(ll i=1;i<=n;i++)for(ll j=1;j<=m;j++)
    #define     Unique(X)         (X).resize(unique(all(X))-(X).begin())
    #define     get_pos(c,x)      (lower_bound(c.begin(),c.end(),x)-c.begin())
    #define     get_pos_up(c,x)   (upper_bound(c.begin(),c.end(),x)-c.begin())
    #define     IOS               ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #define     for2Dpnt(arr,n,m) for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cout<<arr[i][j]<<" ";cout<<endl;}


    /*** STLs ***/
    typedef vector <ll> vll;
    typedef set <ll> sll;
    typedef multiset <ll> msll;
    typedef queue <ll> qll;
    typedef stack <ll> stll;
    typedef map <ll, ll> mll;
    typedef pair <ll, ll> pll;
    typedef vector <pair <ll , ll> > vpll;


    /*** BitWise Operations
    ///int Set(int N,int pos){return N=N | (1<<pos);}
    ///int reset(int N,int pos){return N= N & ~(1<<pos);}
    ///bool check(int N,int pos){return (bool)(N & (1<<pos));}
    ***/


    /*** Grids
    ///const int fx[] = {+1,-1,+0,+0};
    ///const int fy[] = {+0,+0,+1,-1};
    ///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
    ///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
    ///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
    ///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
    ***/


    /*** Functions
    ///transform(data.begin(), data.end(), data.begin(),[](unsigned char c){ return std::tolower(c); });
    ///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
    ///ll toint(string s){ll n=0,k=1;for(int i=s.size()-1; i>=0; i--){n += ((s[i]-'0')*k);k*=10;}return n;}
    ///string tostring(ll x){string s="";while(x){s += (x%10)+'0';x/=10;}reverse(s.begin(),s.end());return s;}
    ///bool sortinrev(const pair<ll,ll> &a,const pair<ll,ll> &b)return (a.first > b.first);
    ///prime[]={2,4,2,4,6,2} //start loop from 29 to do prime factorization
    ///auto it = lower_bound(my_multiset.begin(), my_multiset.end(), 3);
    ///const auto pos = distance(my_multiset.begin(), it);
    ///priority_queue< pll ,vector<pll>,greater<pll> >p;
    ///lower_bound(all(v),r+1)-lower_bound(all(v),l);
    ///cout<<*X.find_by_order(0)<<endl;
    ///cout<<X.order_of_key(-5)<<endl;
    ///set< pair<int,int> >s;
    ///pair<int,int> p={3,2};
    ///auto lb=lower_bound(s.begin(),s.end(),p);
    ///cout<<(*lb).first<<" "<<(*lb).second<<endl;
    ***/


    /*** Some Prints ***/
    #define en cout << '\n';
    #define no cout << "NO" << '\n'
    #define yes cout << "YES" << '\n'


    //__uint128_t
    ll A[mxx*10];
    ll B[mxx*10];


    int main()
    {
        IOS;
        ll tst=1;
        //cin>>tst;
        for(ll tt=1; tt<=tst; tt++)
        {
            //code





















        }


        return 0;
    }
Solution-2
  int whatIsLove() {
    //Comment
  }


Number Theory

Binary Exponentiation [1][2]

      - Binary Exponentiation[1]
      - modular multiplication[2]

Problems

LASTDIG - SPOJ
https://www.spoj.com/problems/LASTDIG/
Solutions
Solution-1
    #include<iostream>
    using namespace std;


    #define          ll     long long int
    void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}


    ll bigmod ( ll a, ll p, ll m )
    {
        ll res = 1;
        ll x = a%m;
        if(x==0)return 0;

        while ( p )
        {
            if ( p & 1 )
            {
                res = ( res * x ) % m;
            }
            x = ( x * x ) % m;
            p = p >> 1;
        }

        return res;
    }

    int main()
    {
         FLASH();
         ll t;
         cin>>t;
         while(t--)
         {
             ll a,b;
             cin>>a>>b;
             cout<<bigmod(a,b,10)<<endl;
         }



        return 0;
    }
LOCKER - SPOJ
https://www.spoj.com/problems/LOCKER/
Solution
https://palak001.medium.com/spoj-locker-magic-of-the-locker-a758bccf432f
ZSUM - SPOJ
https://www.spoj.com/problems/ZSUM/
Solutions
Solution-1
    
    #include <iomanip>
    #include <iostream>
    #include <algorithm>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <string>
    #include <cmath>
    #include <vector>
    #include <set>
    #include <map>
    #include <unordered_set>
    #include <unordered_map>
    #include <stack>
    #include <queue>
    #include <deque>
    #include <iterator>
    #include <bitset>
    #include <assert.h>
    #include <new>
    #include <sstream>
    #include <time.h>


    using namespace std;
    typedef long long ll;
    #define     re                return
    #define     IOS               ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);




    ll bigmod(ll a,ll p,ll m)
    {
        ll x=a%m,res=1;
        if(x==0)re 0;
        while(p){
            if(p&1)res = (res*x)%m;
            x = (x*x)%m;
            p>>=1;
        }
        re res;
    }


    int main()
    {
        IOS;
        ll tst=1;
        //cin>>tst;
        for(ll tt=1;  ;tt++)
        {
            //code
            ll n,k;
            cin>>n>>k;
            if(!n && !k)break;
            ll val=(2*bigmod(n-1,k,MOD))%MOD + bigmod(n,k,MOD) + (2*bigmod(n-1,n-1,MOD))%MOD + bigmod(n,n,MOD);
            cout<<val%MOD<<endl;

        }


        return 0;
    }


Modular Inverse [1][2][3][4]

      - Modular Multiplicative Inverse - forthright48[1]
      - Modular inverse made easy[2]
      - How To Find The Inverse of a Number[3]
      - Modular Multiplicative Inverse - Cp Algorithm[4]

Problems

LOCKER - SPOJ
https://www.spoj.com/problems/LOCKER/
Solution
https://palak001.medium.com/spoj-locker-magic-of-the-locker-a758bccf432f

Sieve of Eratosthenes [1][2][3]

      - Sieve of Eratosthenes - forthright48[1]
      - Sieve of Eratosthenes - Cp Algorithm[2]
      - Segmented Sieve of Eratosthenes -  forthright48[3]

Problems

TDPRIMES - SPOJ
https://www.spoj.com/problems/TDPRIMES/
Solution
https://ideone.com/k3Ykm0

Euclidean Algorithm [1][2]

      - Euclidean Algorithm(Proof) - Youtube[1]
      - Euclidian Algorithm - FreeCodeCamp[2]

Problems

11827 - Maximum GCD
https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&problem=2927
Solution
Solve it!!

Extend Euclidean Algorithm [1][2][3][4][5][6][7]

      - The Extended Euclidean algorithm - Youtube[1]
      - Extended Euclidean Algorithm and Inverse Modulo - FreeCodeCamp[2]
      - এক্সটেন্ডেড ইউক্লিডীয়ান অ্যালগোরিদম - Return 0[3]
      - Extended Euclidean Algorithm - forthright48[4]
      - Linear Diophantine Equation  - forthright48[5]
      - Extended Euclidean Algorithm - Cp Algorithm[6]
      - Linear Diophantine Equation - Cp Algorithm[7]

Problems

Extended Euclidean Algorithm applications
https://codeforces.com/blog/entry/10575?locale=en
Solution
Solve them!!

Chicken McNugget Theorem [1][2][3]

      - Frobenius Coin Problem (Chicken McNugget Theorem) - Youtube[1]
      - Number System Concept 4 ( Chicken Mcnugget Theorem) - Youtube[2]
      - Chicken McNugget Theorem - Medium[3]

Problems

Get AC in one go - CodeChef
https://www.codechef.com/problems/COPR16G
Solution
https://www.codechef.com/viewsolution/63102204

Binomial Coefficients [1][2]

      - Binomial Coefficient using C++ - Youtube[1]
      - Binomial Coefficients - Cp Algorithm[2]

Problems

Get AC in one go - CodeChef
https://www.codechef.com/problems/COPR16G
Solution
https://www.codechef.com/viewsolution/63102204

Sieve of Eratosthenes [1][2][3]

      - Sieve of Eratosthenes, Generating Primes - forthright48[1]
      - Binomial Coefficients - Cp Algorithm[2]
      - Segmented Sieve of Eratosthenes - forthright48[3]

Problems

Get AC in one go - CodeChef
https://www.codechef.com/problems/COPR16G
Solution
https://www.codechef.com/viewsolution/63102204


Combinactorics & Probability

      - Art of Problem Solving: Counting Paths on a Grid - Youtube[1]
      - Navigate a Grid Using Combinations And Permutations - Better Explained[2]
      - Problems on Grids, Paths, and Chessboards for CAT Exam[3]
      - Combinatorics Introduction Correction: nCk = nC(n-k)[Bangla][4]
      - Probabilty + Combinatorics - Intermediate (BACS-BUBT National Programming Camp, 2017)[Bangla][5]
      - Basic of Combinatorics[6]
      - Prufer Code: Linear Representation of a Labeled Tree[7]
      - Application of Prufer Code: Random Tree Generation, Cayley’s Formula and Building Tree from Degree Count[8]
      - The Birthday Problem[9]
      - Medium Math[10]
      - The Monty Hall Problem[11]

Problems

Combinations - LightOj
https://lightoj.com/problem/combinations
Solution
    ll A[1000000];
    map<ll,vector<ll> >ps;
    void fact()
    {
        A[0]=A[1]=1;
        for(ll i=2;i<=1e6+2;i++)
        {
            A[i]=((A[i-1]%MOD)*i)%MOD;
        }
    }

    ll bigmod ( ll a, ll p, ll m )
    {
        ll res = 1;
        ll x = a;

        while ( p )
        {
            if ( p & 1 ) //p is odd
            {
                res = ( res * x ) % m;
            }
            x = ( x * x ) % m;
            p = p >> 1;
        }

        return res;
    }

    int main()
    {
         fact();
         ll t;
         cin>>t;
         for(ll j=1;j<=t;j++)
         {
             ll n,r;
             cin>>n>>r;
             cout<<"Case "<<j<<": ";
             ll a=((A[n-r]%MOD)*(A[r]%MOD))%MOD;
             ll b=((A[n]%MOD)*(bigmod(a,MOD-2,MOD)))%MOD;
             cout<<b<<endl;
         }


        return 0;
    }
Good Predictions - SPOJ
https://www.spoj.com/problems/GOODB/
Solution
     Solve it!!

Star Bars Theorem

Bell Numbers

The Coupon Collector's Problem

Catalan Numbers

Pascal's Triangle properties

Stirling Number [1]

      - What is Stirling Number of First Kind - Youtube[1]

Problems

No Name
No link!!
Solution
   Solve it!!


Theory & Function & Principle

Pigeonhole principle

Search

Binary Search [1][2][3]

      - Introduction to Binary Search - Youtube[1]
      - বাইনারি সার্চ - Shafaet Blog[2]
      - Binary Search - Programiz[3]

Problems

The Playboy Chimp - UVA
https://onlinejudge.org/index.php?option=onlinejudge&Itemid=8&page=show_problem&problem=1552
Solution
   Solve it!!

Fraction Binary Search [1]

      - Introduction to Fraction Binary Search - Github[1]

Problems

Conductors - Timus
https://acm.timus.ru/problem.aspx?space=1&num=1011
Solution
   Solve it!!

Ternary Search [1][2][3]

      - Searching an element in a sorted array (Ternary Search) - Youtube[1]
      - Introduction to Ternary Search - Shafik's Blog[2]
      - Ternary Search - Cp Algorithm[3]

Problems

Help Chokro - Toph
https://toph.co/p/help-chokro
Solution
   Solve it!!

Parallel Binary Search

Dynamic Programming

Basic DP

Bangla

    https://sites.google.com/site/smilitude/recursion_and_dp    
   http://www.shafaetsplanet.com/planetcoding/?p=1022     

Hindi

  https://youtube.com/playlist?list=PL_z_8CaSLPWekqhdCPmFohncHwz8TY2Go     

English

   https://www.codechef.com/certification/data-structures-and-algorithms/prepare#foundation   
   https://www.youtube.com/watch?v=OQ5jsbhAv_M&list=PLcDimPvbmfT8qAxD6JH_kmXiQwTNcoK78  
   https://codeforces.com/blog/entry/67679    

Basic DP Problems

Help Chokro - Toph
    https://toph.co/p/help-chokro
Solution
   Solve it!!

String

KMP(Knuth Morris Pratt) Pattern Searching [1][2][3]

      - Knuth–Morris–Pratt(Bangla) - Youtube[1]
      - স্ট্রিং ম্যাচিং: নুথ-মরিসন-প্র্যাট (কেএমপি) অ্যালগরিদম - Shafaet Blog[2]
      - Prefix function. Knuth–Morris–Pratt algorithm - Cp Algorithm[3]

Problems

Substring Frequency - LighOj
https://lightoj.com/problem/substring-frequency
Solution
   Solve it!!