Cod sursa(job #830704)
Utilizator | Data | 7 decembrie 2012 14:57:49 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
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 = n;
while(k){
if(k==1)
putere= (putere*n) %1999999973;
n = (n*n)%1999999973;
k/=2;
}
fout << putere;
return 0;
}