Cod sursa(job #1965372)
Utilizator | Data | 14 aprilie 2017 12:40:23 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
#define MOD 1999999973
#define ll long long
using namespace std;
ll p(ll a , ll b)
{
if(b==0)return 1;
if(b%2==1)return ((a%MOD)*(p(a,b-1)%MOD))%MOD;
else return ((p(a,b/2)%MOD)*(p(a,b/2)%MOD))%MOD;
}
long long a,b;
int main()
{
ifstream fin ("lgput.in");
ofstream fout("lgput.out");
fin>>a>>b;
fout<<p(a,b);
return 0;
}