Cod sursa(job #3038258)
| Utilizator | Data | 27 martie 2023 09:53:20 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
long long a,b,rez;
long long f (long long a,long long b)
{
if (b==0)
return 1;
else
{
long long p=f (a,b/2)%mod;
if (b%2==0)
return (p*p)%mod;
else
return ((p*p)%mod*a)%mod;
}
}
int main()
{
fin>>a>>b;
a=a%mod;
rez=f (a,b);
fout<<rez;
return 0;
}
