Cod sursa(job #727873)
Utilizator | Data | 28 martie 2012 12:33:43 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long a,b,c;
void citeste(){
f >> a >> b;
c=1999999973;
}
void putere(){
long long rez = 1;
while(b){
if (b % 2 == 1)
rez = (rez * a) % c;
a=(a*a) % c;
b /= 2;
}
g << rez % c<< "\n";;
}
int main(){
citeste();
putere();
f.close();
g.close();
return 0;
}