Cod sursa(job #2706370)
Utilizator | Data | 14 februarie 2021 18:40:12 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int n, p;
const int mod = 1999999973;
int alab(int a, int b)
{
int ans =1, act =a;
while(b!=0)
{
if(b%2==1)
{
ans *= act;
}
act *= act;
act %= mod;
b/=2;
ans%=mod;
}
return ans%mod;
}
int main()
{
fin>>n>>p;
fout<<alab(n,p);
return 0;
}