Sort by

recency

|

46 Discussions

|

  • + 0 comments
    MOD = 10**9 + 7
    
    def mod_expo(base, exponent, modulus):
        result = 1
        base = base % modulus
        while exponent > 0:
            if exponent % 2 == 1:
               result = (result * base) % modulus
            exponent = exponent >> 1
            base = (base * base) % modulus
        return result
    
    T = int(input().strip())
    for _ in range(T):
        A, B = map(int, input().split())
        print(mod_expo(A, B, MOD))
    

    https://retrobowlcollege.com/

  • + 0 comments

    AP government jobs AP Home Guard Jobs 2022 Apply for Home Guard Vacancy in AP. Latest Notification for AP Home Guard Recruitment 2022. Get loose Jobs Alert 2022 AP Home Guard Vacancy 2022.

  • + 2 comments

    Remember AOL conversation channels and downloading tunes through Napster? The web has advanced altogether.Today, it's overpowered by Meta, Google Verse and a humble bundle of other tech beasts whose organizations have simplified it for billions of people to confer and share content on the web.

  • + 0 comments

    C# usin BigInteger (otherwise - russian peasant algorithm):

    private static int longStrToModNum(string a, int m)
    {
        int offs = 18, len = a.Length, idx = len - ((len-1)%offs + 1);
        long fctr = long.Parse($"1{new string('0', (len-1)%offs + 1)}") % m, res = long.Parse(a.Substring(idx)) % m;
        long mod10s = long.Parse($"1{new string('0', offs)}") % m;
        while (idx > 0)
        {
            idx -= offs;
            res = (res + long.Parse(a.Substring(idx, offs)) % m * fctr % m) % m;
            fctr = fctr * mod10s % m;
        }
        return (int)res;
    }
    public static int solve(string a, string b)
    {
        return (int)BigInteger.ModPow(longStrToModNum(a,1000000007), longStrToModNum(b,1000000006), 1000000007);
    }
    

    ...not that speedy, but passing all tests

  • + 0 comments
    #define ll long long 
    
    //a^b % mod
    ll power(ll a, ll b, ll mod){
        int ans = 1;
        while(b){
            if(b&1)
                ans = (ans * a) % mod;
            b /= 2;
            a = a * a % mod; 
        }
        return ans;
    }
    
    int solve(string str1, string str2) {
        ll mod = 1e9+7;
        long long  a = 0 , b = 0;
        
        //reduce b using Euler's theorem ---> a^(m-1) = 1 mod m
        for(ll i=0;i<str2.length();++i){
            b = (b * 10 + (str2[i]-'0'))%(mod-1);
        }
        
        //reduce a using mod 
        for(ll i=0;i<str1.length();++i){
            a = (a * 10 + (str1[i]-'0'))%mod;
        } 
    
        return power(a,b,mod);
    }