Cod sursa(job #2925628)
Utilizator | Data | 15 octombrie 2022 20:15:31 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.2 kb |
#include<fstream>
long long y=1,x,N=2e9-27,p;
int main()
{
for(std::ifstream("lgput.in")>>x>>p;p;p>>=1,x=x*x%N)
if(p&1)
y=x*y%N;
return std::ofstream("lgput.out")<<y,0;
}