fork download
  1. #include <stdio.h>
  2.  
  3. void test_lcg(const char * const source, const unsigned a, const unsigned c)
  4. {
  5. unsigned x = 0;
  6. unsigned long long n = 0;
  7. printf("%s\nx = x * %u + %u\n", source, a, c);
  8. do {
  9. x = x * a + c;
  10. ++n;
  11. } while (x);
  12. printf("cycle length: %llu\n\n", n);
  13. }
  14.  
  15. int main()
  16. {
  17. printf("https://e...content-available-to-author-only...a.org/wiki/Linear_congruential_generator\n\n");
  18. test_lcg("Numerical Recipes", 1664525, 1013904223);
  19. test_lcg("Borland C/C++", 22695477, 1);
  20. test_lcg("Borland Delphi", 134775813, 1);
  21. test_lcg("Turbo Pascal", 33797, 1);
  22. test_lcg("Microsoft Visual C/C++", 214013, 2531011);
  23. test_lcg("old glibc", 69069, 1);
  24. return 0;
  25. }
Time limit exceeded #stdin #stdout 5s 2168KB
stdin
Standard input is empty
stdout
Standard output is empty