Cod sursa(job #2373898)
Utilizator | Data | 7 martie 2019 15:43:30 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <bits/stdc++.h>
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
long long b,p,nr,i=1,sol=1;
fin>>b>>p;
nr=b;
while(p!=0)
{
if((i&p)==i)
sol*=nr,p-=i;
i+=i;
nr*=nr;
nr%=MOD;
sol%=MOD;
}
fout<<sol;
return 0;
}