You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
583 B

#include "utils.h"
#include <cmath>
std::map<internal::PowModStruct,int>utils::mapping;
int utils::PowMod(int a,int b, int mod){
int shift=0;
for(int n=1;n<=b;n*=2){
if(utils::mapping.find({a,n,mod})!=utils::mapping.end()){
std::cout<<internal::PowModStruct{a,n,mod}<<"="<<utils::mapping[{a,n,mod}]<<std::endl;
continue;
}
std::cout<<std::fmod(std::pow(double(a),double(n)),double(mod))<<std::endl;
utils::mapping[{a,n,mod}]=std::fmod(std::pow(double(a),double(n)),double(mod));
shift++;
}
return 0;
}