Cod sursa(job #1059412)
Utilizator | Data | 16 decembrie 2013 17:40:45 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include<fstream>
using namespace std;
const int mod = 1999999973;
int main() {
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n, p, aux = 1;
fin >> n >> p;
while(p) {
if(p % 2 == 1) {
aux *= n;
aux %= mod;
}
n *= n;
n %= mod;
p /= 2;
}
fout << aux;
return 0;
}