Cod sursa(job #2118351)
| Utilizator | Data | 30 ianuarie 2018 16:03:15 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long a, b;
long long exp(long long x, long long y);
int main()
{
fin>>a>>b;
fout<<exp(a, b)%mod;
return 0;
}
long long exp(long long x, long long y)
{
if (y==0)
return 1;
else if (y%2==0)
return exp(x*x%mod, y/2);
else return exp(x*x%mod, y/2)*x%mod;
}
