Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void lcg(vector<int>& r, int seed, int size, int a, int c, long m){
- if (size == 1){
- r.push_back((a*seed+c)%m);
- return;
- }
- for(int i = 0; i < size; ++i){
- r.push_back(0);
- }
- r[0] = seed;
- for(int i = 1; i < size; ++i){
- r[i] = (a*r[i-1]+c)%m;
- }
- r.erase(r.begin());
- }
- void generate(int seed, long size, double a2b, double i2u, vector<int> & a, vector<int>& b){
- //hardcoded consts for lcg generator
- //a = 50001
- //c = 49999
- //m = 2500000000
- int inter = int(size*i2u);
- int a_size = int(a2b*size*(1-i2u)/(a2b+1))+inter;
- int b_size = int(size*(1-i2u)/(a2b+1))+inter;
- lcg(a, seed, a_size, 50001, 49999, 2500000000);
- lcg(b, a[a_size - inter],b_size, 50001, 49999, 2500000000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement