Advertisement
HellFinger

Untitled

Feb 9th, 2022
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. void lcg(vector<int>& r, int seed, int size, int a, int c, long m){
  2. if (size == 1){
  3. r.push_back((a*seed+c)%m);
  4. return;
  5. }
  6. for(int i = 0; i < size; ++i){
  7. r.push_back(0);
  8. }
  9. r[0] = seed;
  10. for(int i = 1; i < size; ++i){
  11. r[i] = (a*r[i-1]+c)%m;
  12. }
  13. r.erase(r.begin());
  14. }
  15.  
  16.  
  17.  
  18. void generate(int seed, long size, double a2b, double i2u, vector<int> & a, vector<int>& b){
  19. //hardcoded consts for lcg generator
  20. //a = 50001
  21. //c = 49999
  22. //m = 2500000000
  23. int inter = int(size*i2u);
  24. int a_size = int(a2b*size*(1-i2u)/(a2b+1))+inter;
  25. int b_size = int(size*(1-i2u)/(a2b+1))+inter;
  26. lcg(a, seed, a_size, 50001, 49999, 2500000000);
  27. lcg(b, a[a_size - inter],b_size, 50001, 49999, 2500000000);
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement