Cod sursa(job #3004798)
Utilizator | Data | 16 martie 2023 16:51:47 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
#define ll long long
const ll MOD=1999999973;
ll fastpower(ll a,ll b){
ll rez=1;
while(b){
if(b%2){
rez=(rez*a)%MOD;
}
a=(a*a)%MOD;
b/=2;
}
return rez;
}
int main(){
ll a,b;
f>>a>>b;
g<<fastpower(a,b);
return 0;
}