Cod sursa(job #1972278)
Utilizator | FMI Tilica Robert Robert29 | Data | 22 aprilie 2017 18:12:30 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include<fstream>
#define mod 1999999973;
using namespace std;
ifstream cin("lgput.in");
ofstream cout("lgput.out");
long long Pow(long long x, long long n)
{
long long p = 1;
while(n)
{
if(n % 2)
{
p = (p * x) % mod;
}
x = (x * x) % mod;
n /= 2;
}
return p;
}
int main(){
long long x, n;
cin >> x >> n;
cout << Pow(x, n);
cin.close();
cout.close();
return 0;
}