Cod sursa(job #2370953)
Utilizator | Data | 6 martie 2019 14:46:17 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include<bits/stdc++.h>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long sol,n,p;
int main()
{
f>>n>>p;
sol=1;
while(p)
{
if(p%2==0)
n=(n*n)%1999999973,p/=2;
else
sol=(sol*n)%1999999973,p--;
}
g<<sol;
return 0;
}