Cod sursa(job #880238)
Utilizator | Data | 16 februarie 2013 15:17:51 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
long long int x=1,A,B;
long long int modulo(long long int a,long long int b)
{
while(b>0)
if(b%2!=0)
{
x=(x*a)%1999999973;b--;
}
else {a=(a*a)%1999999973; b/=2;}
return x;
}
int main ()
{
in>>A>>B;
out<<modulo(A,B);
}