Cod sursa(job #2073953)
Utilizator | Data | 23 noiembrie 2017 21:24:47 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <fstream>
#define MOD %1999999973
#define ll long long
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
ll putere( ll x, ll n)
{
ll p = 1;
while(n>0)
{
if( n % 2 )
{
p = ( p* x) MOD;
n--;
}
x = (x*x) MOD;
n /=2;
}
return p;
}
int main()
{
ll x,n; in >> x >> n;
out << putere(x,n);
return 0;
}