Cod sursa(job #2434025)
Utilizator | Data | 30 iunie 2019 13:30:10 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <fstream>
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int n,p;
int main(){
fin>>n>>p;
long long x=1;
while(p){
if(p%2){
x*=n;
x%=MOD;
}
n*=n;
n%=MOD;
p/=2;
}
fout<<x%MOD;
return 0;
}