Cod sursa(job #830706)
Utilizator | Data | 7 decembrie 2012 15:05:35 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include<iostream>
#include<fstream>
using namespace std;
long long putere, n, k;
int main(){
ifstream fin("lgput.in");
ofstream fout("lgput.out");
fin >> n >> k;
putere = 1;
while(k){
if(k%2==1)
putere= (putere*n) %1999999973;
n = (n*n)%1999999973;
k/=2;
}
fout << putere;
return 0;
}