Cod sursa(job #2207484)
Utilizator | Data | 25 mai 2018 19:30:51 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include <fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
const int R=1999999973;
int main()
{
long long n,p,a;
in>>a>>n;
p=1;
while(n!=0)
{
if(n%2!=0)
{
p=p*a%R;
}
n/=2;
a=a*a%R;
}
out<<p;
return 0;
}