Cod sursa(job #1182409)
Utilizator | Data | 6 mai 2014 12:40:35 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
using namespace std;
int main(){
ifstream ifs("lgput.in");
ofstream ofs("lgput.out");
int x,n;ifs>>x>>n; // x^n
long long int a=1;
while(n!=0){
if(n%2){
ans*=x;
x*=x;
n>>=1;
}
else{
x*=x;
n>>=1;
}
}
ofs<<a%1999999973;
}