Cod sursa(job #533095)
| Utilizator | Data | 13 februarie 2011 01:11:31 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.58 kb |
#include <algorithm>
#include <fstream>
using namespace std;
const char Input[] = "lgput.in";
const char Output[] = "lgput.out";
const int Mod = 1999999973;
long long int N, P, XXX;
int main() {
ifstream fin( Input );
ofstream fout( Output );
int i;
long long int aux;
fin >> N >> P;
XXX = 1;
aux = N;
for( i = 0; (1LL << i) <= P; ++i ) {
if( (1LL << i) & P )
XXX = (XXX * aux) % Mod;
aux = (aux * aux) % Mod;
}
fout << XXX;
fin.close();
fout.close();
return 0;
}
