Cod sursa(job #2219929)
Utilizator | Data | 10 iulie 2018 00:20:40 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
const int modd = 1999999973;
int main()
{
long long int x,y;
long long int sol=1;
in>>x>>y;
while(y>0)
{
if(y%2==1)
{
y--;
sol=sol*x%modd;
}
x=(x*x)%modd;
y=y/2;
}
out<<sol;
}