Cod sursa(job #1691729)
Utilizator | Data | 19 aprilie 2016 12:04:24 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include<fstream>
#define MOD 1999999973LL
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n, p;
long long lgput( long long x, long long p ){
long long r = 1;
while( p != 0 ){
if( p % 2 == 1 ){
r = r * x % MOD;
}
x = x * x % MOD;
p /= 2;
}
return r;
}
int main(){
fin >> n >> p;
fout << lgput( n, p );
return 0;
}