Cod sursa(job #2848671)
| Utilizator | Data | 13 februarie 2022 00:06:50 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <iostream>
#include <fstream>
using namespace std;
#define MOD 1999999973
#define int long long
ifstream fin( "lgput.in" );
ofstream fout( "lgput.out" );
int lgput( int n, int put ) {
int rez = 1;
while( put > 0 ) {
if( put % 2 == 1 )
rez = rez * n % MOD;
n = n * n % MOD;
put /= 2;
}
return rez;
}
signed main() {
int n, p;
fin >> n >> p;
fout << lgput( n, p );
return 0;
}
