We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Mathematics
  3. Fundamentals
  4. Matrix Tracing
  5. Discussions

Matrix Tracing

Problem
Submissions
Leaderboard
Discussions
Editorial

    You are viewing a single comment's thread. Return to all comments →

  • Mohit_Yadav_389
    5 years ago+ 0 comments

    If anyone want euclid's extended algo; Here we go;

    int mmi(int a, int m){
        if(a==1)return 1;
        int e=m;
        int f=a;
        int x= 0;
        int y= 1;
        unsigned long long  u = 1;
        int v = 0;
        int q=0,r=0,c=0,d=0;
        while(f!=1){
            q = e/f; r = e%f; c = x- q*u; d = y - q*v; x = u; y = v; u = c; v = d; e = f; f = r;
        }
        return (u+m)%m;
    }
    
    7|
    Permalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature