Cod sursa(job #2781636)
Utilizator | Data | 10 octombrie 2021 00:47:41 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
using namespace std;
int main( ) {
ifstream fin ( "lgput.in" );
ofstream fout ( "lgput.out" );
long long n, p, r = 1;
fin >> n >> p;
while ( p > 0 ){
if ( p % 2 == 1 )
r = ( r * n ) % 1999999973;
n = ( n * n ) % 1999999973;
p = p / 2;
}
fout << r;
return 0;
}