Cod sursa(job #1982240)
Utilizator | Data | 17 mai 2017 22:51:00 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 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*=x;
n--;
}
x=x*x;
n /=2;
}
return p;
}
int main()
{
ifstream in("lgput.in");
ofstream out("lgput.out");
ll x,n; in>>x>>n;
out<<putere( x, n)%1999999973;
return 0;
}