Cod sursa(job #2638294)
| Utilizator | Data | 27 iulie 2020 18:04:15 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long int n,m;
long long int exec (int x,int exp)
{
if (exp==0) return 1;
if (exp==1) return x;
else if (exp%2==0)
{
return exec(x,exp/2)*exec(x,exp/2)%1999999973;
}
else return (exec(x,exp-1)*x)%1999999973;
}
int main()
{
f>>n>>m;
g<<exec(n,m);
return 0;
}
