Cod sursa(job #3038264)
Utilizator | Data | 27 martie 2023 10:00:23 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 60 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
#define mod 1999999973
long long n,p;
int main(){
fin>>n>>p;
long long x=1;
long long n2=n;
while(x<p){
if(2*x<p)
n2*=n2,x*=2,n2%=mod;
else
x++,n2*=n,n2%=mod;
}
fout<<n2;
return 0;
}