Cod sursa(job #1166726)
Utilizator | Data | 3 aprilie 2014 19:29:53 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include<iostream>
#include<fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;
int n, p, rez;
int main() {
fin >> n >> p;
rez = 1;
while(p != 0) {
if(p%2) {
rez = (rez * n) % MOD;
p--;
}
n = (n * n) % MOD;
p /= 2;
}
fout << rez;
fin.close();
fout.close();
return 0;
}