Cod sursa(job #1711201)

Utilizator Spiromanii_MessiUNIBUCThrowTerror Spiromanii_Messi Data 30 mai 2016 20:08:50
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.7 kb
#include <bits/stdc++.h>

using namespace std;

# define pb push_back
# define mp make_pair
# define FORN( a , b , c ) for ( int a = b ; a <= c ; ++ a )
# define FORNBACK( a , b , c ) for ( int a = b ; a >= c ; -- a )

const int MOD = 1999999973 ;

int put ( int x , int y ) {
    int ret = 1 ;
    while ( y ) {
        if ( y % 2 == 1 ) {
            ret = 1LL * ret * x % MOD ;
        }
        x = 1LL * x * x % MOD ;
        y /= 2 ;
    }
    return ret ;
}

int main()
{
    ios :: sync_with_stdio ( false ) ;

    freopen( "lgput.in" , "r" , stdin ) ;
    freopen( "lgput.out" , "w" , stdout ) ;
    int a , b ;
    cin >> a >> b ;
    cout << put ( a , b ) ;
    return 0 ;
}