Cod sursa(job #1982242)
Utilizator | Data | 17 mai 2017 22:54:43 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
typedef long long ll;
using namespace std;
ll putere(ll x, ll n){
ll p=1;
while ( n>0){
if ( n%2==1){
p=(p*x) % 1999999973;
n--;
}
x=(x*x) %1999999973;
n /=2;
}
return p;
}
int main()
{
ifstream in("lgput.in");
ofstream out("lgput.out");
ll x,n; in>>x>>n;
out<<putere( x, n);
return 0;
}