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