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