Cod sursa(job #877664)
| Utilizator | Data | 13 februarie 2013 01:13:17 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.4 kb |
#include <iostream>
#include <fstream>
using namespace std;
typedef long long int64;
const int64 MOD = 1999999973;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main() {
int N, P;
fin >> N >> P;
int64 rez = 1;
int64 p = 1, lg_p = N;
while (p <= P) {
if (p & P) rez = (rez * lg_p) % MOD;
lg_p = (lg_p * lg_p) % MOD;
p *= 2;
}
fout << rez;
}
