Cod sursa(job #2249259)
Utilizator | Data | 29 septembrie 2018 14:54:22 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <bits/stdc++.h>
#define VAL 1999999973
using namespace std;
int main() {
long long a, b, p;
ifstream fin( "lgput.in" );
fin >> a >> b;
fin.close();
p = 1;
while ( b ) {
p %= VAL;
if ( b % 2 == 1 )
p *= a;
a = ( a * a ) % VAL;
b /= 2;
}
ofstream fout( "lgput.out" );
fout << p;
fout.close();
return 0;
}