1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#ifndef CNST_H
#define CNST_H
class cnst
{
public:
const long long p;
const long long q;
const long long n;
const long long phi;
const int N;
const int k;
const long long e;
const long long d;
long long inverse(long long,long long);
cnst(long long,long long,long long,int);
};
cnst::cnst(long long _p,long long _q,long long _e,int _N):
p(_p),
q(_q),
n(_p*_q),
phi((_p-1)*(_q-1)),
N(_N),
k((int)(log((long double)n)/log((long double)N))),
e(_e),
d(inverse(phi,e))
{}
long long cnst::inverse(long long m,long long r)
{
if(r==1)
return r;
int t;
t=inverse(r,(m%r));
return ((((r-t)*m)+1)/r)%phi;
}
#endif
|