Cod sursa(job #2664241)
| Utilizator | Data | 28 octombrie 2020 10:52:08 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin( "lgput.in" );
ofstream fout( "lgput.out" );
const int MOD = 1999999973;
int N, P;
int QuickExp( int n, int pw ) {
if( pw == 1 ) return n % MOD;
int ans = QuickExp( n, pw / 2 );
ans = ( 1LL * ans * ans ) % MOD;
if( pw % 2 ) ans = ( 1LL * ans * n ) % MOD;
return ans;
}
int main()
{
fin >> N >> P;
fout << QuickExp( N, P );
return 0;
}
