Cod sursa(job #490047)
Utilizator | Data | 4 octombrie 2010 19:49:32 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
int x,n;
long long rez=1;
void prelucrare(){
while(n!=0){
if(n%2!=0){
rez=(long long)rez*x%1999999973;
}
x=(long long)x*x%1999999973;
n=n/2;
}
}
int main(){
in>>x>>n;
prelucrare();
out<<rez;
return 0;
}