Cod sursa(job #911522)
Utilizator | Data | 11 martie 2013 19:14:19 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include<fstream>
#define ull long long
using namespace std;
ull a, b, c=1999999973;
ifstream f("lgput.in");
ofstream g("lgput.out");
ull putere(ull x, ull n)
{
ull r=1;
while(n!=0){
if(n%2)
r=(r*(x%c))%c;
n/=2;
x=((x%c)*(x%c))%c;
}
return r;
}
int main()
{
f>>a>>b;
g<<putere(a,b);
return 0;
}