Cod sursa(job #3002300)
| Utilizator | Data | 14 martie 2023 17:21:33 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 20 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.42 kb |
#include <fstream>
#define int long long
using namespace std;
ifstream cin("lgput.in");
ofstream cout("lgput.out");
const int MOD = 1999999973;
int x , p;
int fastpow( int putere ){
if(!putere) return 1LL;
if(putere%2) return x*fastpow(putere-1);
int x = fastpow(putere/2);
return(x*x)%MOD;
}
signed main(){
cin >> x >> p;
cout << fastpow(p);
return 0;
}
