Cod sursa(job #2281825)
Utilizator | Data | 12 noiembrie 2018 19:43:13 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
typedef long long Int;
const Int MOD= 1999999973LL;
int putere(Int baza,Int expo)
{
Int rez=1LL;
while(expo)
{
if(expo%2)
rez=rez*baza%MOD;
baza=baza*baza%MOD;
}
return rez;
}
Int n,p;
int main(){
f>>n>>p;
g<<putere(n,p);
return 0;
}