fork download
  1. #define _CRT_SECURE_NO_DEPRECATE
  2. #include <stdio.h>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <stdlib.h>
  6. #include <ctime>
  7. #include <set>
  8. #include <map>
  9. #include <queue>
  10. #include <string>
  11. #include <math.h>
  12. #include <queue>
  13. #include <memory.h>
  14. #include <iostream>
  15. #include <stack>
  16. #include <complex>
  17. #include <list>
  18.  
  19. using namespace std;
  20.  
  21. void ASS(bool b)
  22. {
  23. if (!b)
  24. {
  25. ++*(int*)0;
  26. }
  27. }
  28.  
  29. #define FOR(i, x) for (int i = 0; i < (int)(x); i++)
  30. #define CL(x) memset(x, 0, sizeof(x))
  31. #define CLX(x, y) memset(x, y, sizeof(x))
  32.  
  33. #pragma comment(linker, "/STACK:106777216")
  34.  
  35. typedef vector<int> vi;
  36.  
  37. typedef long long LL;
  38.  
  39. double F(double n, double d)
  40. {
  41. return 1 - exp(- n * (n - 1) / (2 * d));
  42. }
  43.  
  44. int main()
  45. {
  46. double n = 1e6;
  47. double d = pow(2.0, 64.0);
  48. // there is collision on one random test case
  49. printf("%0.20lf\n", F(n, d));
  50. double k = 100;
  51. // there is no any coollisions on k test cases
  52. printf("%0.20lf\n", 1 - pow(1 - F(n, d), k));
  53. // there is coollision on k test cases
  54. printf("%0.20lf\n", pow(1 - F(n, d), k));
  55. // there is coollision on k test cases (the same as previous)
  56. printf("%0.20lf\n", exp(k * - n * (n - 1) / (2 * d)));
  57. double solCnt = 51;
  58. // there is collision in any of solCnt solutions on k test cases
  59. printf("%0.20lf\n", pow(1 - F(n, d), k * solCnt));
  60. // there is no any collision in any of solCnt solutions on k test cases
  61. printf("%0.20lf\n", 1 - pow(1 - F(n, d), k * solCnt));
  62. return 0;
  63. }
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
0.00000002710502688963
0.00000271049905231635
0.99999728950094768365
0.99999728950095267965
0.99986177391509512002
0.00013822608490487998