Cod sursa(job #2586898)
| Utilizator | Data | 21 martie 2020 18:15:50 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 40 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.41 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;
if (b==2)
return 1LL*a%M*a%M;
if (b%2==0)
return pow(pow(a,b/2),2);
else return 1LL*pow(pow(a,b/2),2)*a;
}
int main ()
{
ci>>a>>b;
co<<pow(a,b);
return 0;
}
