Cod sursa(job #2529133)
Utilizator | Data | 22 ianuarie 2020 23:09:22 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <iostream>
#include <fstream>
using namespace std;
const int MOD = 1999999973;
int main() {
ifstream fin( "lgput.in" );
ofstream fout( "lgput.out" );
int n;
long long a, prod;
fin >> a >> n;
prod = 1;
while ( n > 0 ) {
if ( n % 2 == 1 )
prod = prod * a % MOD;
a = a * a % MOD;
n /= 2;
}
fout << prod;
return 0;
}