Cod sursa(job #2341980)

Utilizator Hexor_ALXAlexandru Olteanu Hexor_ALX Data 12 februarie 2019 14:47:33
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-32 Status done
Runda Arhiva educationala Marime 0.87 kb
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll const mod=1000000007;
ll const md=998244353;
ll mypowr(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);
for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll mypow(ll a,ll b) {ll res=1;assert(b>=0);
for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}
ifstream in("lgput.in");
ofstream out("lgput.out");
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second



int main()
{   cout<<fixed<<setprecision(12);
    cin.tie(0);cout.tie(0);
    ios_base::sync_with_stdio(0);

    ll a,b;
    in>>a>>b;
    ll y=1;
    while(b!=1){
        if(b&1){
            y*=a;
            y%=1999999973;--b;
        }
        if(b>1)a*=a;
        a%=1999999973;
        b/=2;
    }
    a*=y;
    a%=1999999973;
    out<<a<<'\n';




    return 0;
}