Cod sursa(job #2586893)
| Utilizator | Data | 21 martie 2020 18:11:24 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
#include <fstream>
#define M 1999999973
using namespace std;
ifstream ci ("lgput.in");
ofstream co ("lgput.out");
long long a,b;
long long pow (long long a,long long b)
{
if (b==1)
return a%M;
if (b==2)
return 1LL*a%M*a%M;
if (b%2==0)
return pow(pow(a%M,b/2)%M,2)%M;
else return pow(pow(a%M,b/2)%M,2)%M*a%M;
}
int main ()
{
ci>>a>>b;
co<<pow(a,b)%M;
return 0;
}
