1
0

gen.cpp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. #include "testlib.h"
  2. #include <iostream>
  3. #include <sstream>
  4. #include <fstream>
  5. #include <iomanip>
  6. #include <string>
  7. #include <cstdlib>
  8. #include <cstdio>
  9. #include <cstring>
  10. #include <cmath>
  11. #include <ctime>
  12. #include <climits>
  13. #include <cassert>
  14. #include <vector>
  15. #include <queue>
  16. #include <stack>
  17. #include <deque>
  18. #include <set>
  19. #include <map>
  20. #include <bitset>
  21. #include <utility>
  22. #include <algorithm>
  23. #define forn(i, n) for (int i = 0; i < int(n); i++)
  24. using namespace std;
  25. int main(int argc, char* argv[])
  26. {
  27. registerGen(argc, argv, 1);
  28. int n = opt<int>(1);
  29. int t = opt<int>(2);
  30. vector<int> p(n);
  31. forn(i, n)
  32. if (i > 0)
  33. p[i] = rnd.wnext(i, t);
  34. println(n);
  35. vector<int> perm(n);
  36. forn(i, n)
  37. perm[i] = i;
  38. shuffle(perm.begin() + 1, perm.end());
  39. vector<pair<int,int> > edges;
  40. for (int i = 1; i < n; i++)
  41. if (rnd.next(2))
  42. edges.push_back(make_pair(perm[i], perm[p[i]]));
  43. else
  44. edges.push_back(make_pair(perm[p[i]], perm[i]));
  45. shuffle(edges.begin(), edges.end());
  46. for (int i = 0; i + 1 < n; i++)
  47. println(edges[i].first + 1, edges[i].second + 1);
  48. println(rnd.next("[a-z]{100}"));
  49. printf("%.04f\n", rnd.next(3.1415));
  50. {
  51. long long LL = 12345678901234LL;
  52. long long LR = 82345678901234LL;
  53. println(rnd.next(LL, LR));
  54. }
  55. {
  56. unsigned long long LL = 1345678901234ULL;
  57. unsigned long long LR = 8345678901234ULL;
  58. println(rnd.next(LL, LR));
  59. }
  60. {
  61. unsigned long LL = 134567UL;
  62. unsigned long LR = 834567UL;
  63. println(rnd.next(LL, LR));
  64. }
  65. {
  66. int LL = 134567;
  67. int LR = 834567;
  68. println(rnd.next(LL, LR));
  69. }
  70. vector<int> a;
  71. forn(i, 100)
  72. a.push_back(i * i);
  73. println(rnd.any(a));
  74. println(rnd.perm(10));
  75. println(rnd.perm(0));
  76. println(rnd.perm(0, 1));
  77. println(rnd.perm(10, 1));
  78. println(rnd.distinct(10, 15, 100));
  79. println(rnd.distinct(0, 15, 100));
  80. println(rnd.partition(10, 100, 3));
  81. println(rnd.partition(0, 0, 10));
  82. println(rnd.partition(1, 0, 0));
  83. println(rnd.wnext(1000, 2));
  84. println(rnd.wnext(1000LL, 2LL));
  85. println(rnd.wnext(1000, 20));
  86. println(rnd.wnext(1000LL, 20LL));
  87. println(rnd.wnext(100000, 200));
  88. println(rnd.wnext(100000LL, 200LL));
  89. std::cout << std::fixed << std::setprecision(4) << rnd.next((float) 42.0, (float) 2011.1109) << std::endl;
  90. std::cout << std::fixed << std::setprecision(4) << rnd.next((double) 42.0, (double) 2011.1109) << std::endl;
  91. std::cout << std::fixed << std::setprecision(4) << rnd.wnext((float) 42.0, (float) 2011.1109, 5) << std::endl;
  92. std::cout << std::fixed << std::setprecision(4) << rnd.wnext((double) 42.0, (double) 2011.1109, 5) << std::endl;
  93. std::cout << std::fixed << std::setprecision(4) << rnd.wnext((float) 42.0, (float) 2011.1109, -7) << std::endl;
  94. std::cout << std::fixed << std::setprecision(4) << rnd.wnext((double) 42.0, (double) 2011.1109, -7) << std::endl;
  95. std::cout << rnd.next((unsigned long long) 42, (unsigned long long) 2011) << std::endl;
  96. std::cout << rnd.next((unsigned int) 42, (unsigned int) 2011) << std::endl;
  97. std::cout << rnd.next((unsigned short) 42, (unsigned short) 2011) << std::endl;
  98. std::cout << rnd.wnext((unsigned long long) 42, (unsigned long long) 2011, -3) << std::endl;
  99. std::cout << rnd.wnext((unsigned int) 42, (unsigned int) 2011, -3) << std::endl;
  100. std::cout << rnd.wnext((unsigned short) 42, (unsigned short) 2011, -3) << std::endl;
  101. std::cout << rnd.wnext((unsigned long long) 42, (unsigned long long) 2011, 3) << std::endl;
  102. std::cout << rnd.wnext((unsigned int) 42, (unsigned int) 2011, 3) << std::endl;
  103. std::cout << rnd.wnext((unsigned short) 42, (unsigned short) 2011, 3) << std::endl;
  104. std::cout << rnd.wnext((signed long long) 42, (signed long long) 2011, -5) << std::endl;
  105. std::cout << rnd.wnext((signed int) 42, (signed int) 2011, -5) << std::endl;
  106. std::cout << rnd.wnext((signed short) 42, (signed short) 2011, -5) << std::endl;
  107. std::cout << rnd.wnext((signed long long) 42, (signed long long) 2011, 4) << std::endl;
  108. std::cout << rnd.wnext((signed int) 42, (signed int) 2011, 4) << std::endl;
  109. std::cout << rnd.wnext((signed short) 42, (signed short) 2011, 4) << std::endl;
  110. println(rnd.wany(a, 1));
  111. println(rnd.wany(a, -1));
  112. set<string> b;
  113. b.insert("a"); b.insert("b"); b.insert("c"); b.insert("d"); b.insert("e"); b.insert("f"); b.insert("g");
  114. println(rnd.any(b));
  115. {
  116. std::set<std::string> string_set;
  117. string_set.insert("a");
  118. string_set.insert("b");
  119. string_set.insert("c");
  120. string_set.insert("d");
  121. string_set.insert("e");
  122. string_set.insert("f");
  123. std::cout << rnd.any(string_set) << std::endl;
  124. std::cout << rnd.any(string_set.begin(), string_set.end()) << std::endl;
  125. std::cout << rnd.wany(string_set, 1) << std::endl;
  126. std::cout << rnd.wany(string_set.begin(), string_set.end(), 1) << std::endl;
  127. std::cout << rnd.wany(string_set, -1) << std::endl;
  128. std::cout << rnd.wany(string_set.begin(), string_set.end(), -1) << std::endl;
  129. }
  130. {
  131. std::multiset<std::string> string_multiset;
  132. string_multiset.insert("a");
  133. string_multiset.insert("b"); string_multiset.insert("b");
  134. string_multiset.insert("c"); string_multiset.insert("c"); string_multiset.insert("c");
  135. string_multiset.insert("d");
  136. string_multiset.insert("e"); string_multiset.insert("e"); string_multiset.insert("e");
  137. string_multiset.insert("f"); string_multiset.insert("f"); string_multiset.insert("f"); string_multiset.insert("f");
  138. std::cout << rnd.any(string_multiset) << std::endl;
  139. std::cout << rnd.any(string_multiset.begin(), string_multiset.end()) << std::endl;
  140. std::cout << rnd.wany(string_multiset, 2) << std::endl;
  141. std::cout << rnd.wany(string_multiset.begin(), string_multiset.end(), 1) << std::endl;
  142. std::cout << rnd.wany(string_multiset, -1) << std::endl;
  143. std::cout << rnd.wany(string_multiset.begin(), string_multiset.end(), -2) << std::endl;
  144. }
  145. }