Cod sursa(job #2569285)
Utilizator | Data | 4 martie 2020 11:44:28 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
unsigned long long p=1,m,n,exp;
fin>>n>>exp;
m=1999999973;
while(exp)
{
if(exp%2==1)
p=(p*n)%m;
n=(n*n)%m;
exp/=2;
}
fout<<p;
return 0;
}