Cod sursa(job #3209577)
Utilizator | Data | 2 martie 2024 20:46:01 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <bits/stdc++.h>
#define nr 1999999973
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
long long x, y;
long long exp(long long x, long long y)
{
long long n=1;
x%=nr;
while(y)
{
if(y%2==1) n*=x%nr;
x*=x%nr;
y/=2;
}
return n;
}
int main()
{
in>>x>>y;
out<<exp(x, y);
return 0;
}