fork download
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <algorithm>
  4. #include <string>
  5. #include <cstring>
  6. #include <vector>
  7. #include <stack>
  8. #include <queue>
  9. #include <deque>
  10. #include <map>
  11. #include <set>
  12. #include <limits>
  13. #include <climits>
  14. #include <cmath>
  15. #include <functional>
  16. #include <ctime>
  17. #include <cstdlib>
  18. #include <fstream>
  19. #include <typeinfo>
  20. #include <cassert>
  21. #include <unordered_map>
  22. #include <unordered_set>
  23.  
  24. #define debug(x) cout<<(x)<<'\n'
  25.  
  26. #define endl '\n'
  27. #define remainder safdskhaslfa
  28. #define pow aafkhffhlgsdas
  29. #define distance dagkjsdsdsara
  30. #define left askfjasieqwskajdaks
  31.  
  32. using namespace std;
  33.  
  34. typedef long long int ll;
  35. typedef short int i16;
  36. typedef unsigned long long int u64;
  37. typedef unsigned int u32;
  38. typedef unsigned short int u16;
  39. typedef unsigned char u8;
  40.  
  41. bool used[128][128][128];
  42. double state[128][128][128];
  43.  
  44. double recurse1(int r, int s, int p) {
  45. if(p==0 && s==0) {
  46. if(r==0) return 0.0;
  47. return 1.0;
  48. }
  49.  
  50. if(r==0) {
  51. return 0.0;
  52. }
  53.  
  54. if(used[r][s][p]) return state[r][s][p];
  55.  
  56. double ans=0.0;
  57. int total=r*s+r*p+p*s;
  58.  
  59. if(r>0 && s>0) {
  60. ans+=(double)r*s/(double)total*recurse1(r,s-1,p);
  61. }
  62.  
  63. if(r>0 && p>0) {
  64. ans+=(double)r*p/(double)total*recurse1(r-1,s,p);
  65. }
  66.  
  67. if(p>0 && s>0) {
  68. ans+=(double)p*s/(double)total*recurse1(r,s,p-1);
  69. }
  70.  
  71. used[r][s][p]=true;
  72. state[r][s][p]=ans;
  73.  
  74. return ans;
  75. }
  76.  
  77. double recurse2(int r, int s, int p) {
  78. if(r==0 && p==0) {
  79. if(s==0) return 0.0;
  80. return 1.0;
  81. }
  82.  
  83. if(s==0) {
  84. return 0.0;
  85. }
  86.  
  87. if(used[r][s][p]) return state[r][s][p];
  88.  
  89. double ans=0.0;
  90. int total=r*s+r*p+p*s;
  91.  
  92. if(r>0 && s>0) {
  93. ans+=(double)r*s/(double)total*recurse2(r,s-1,p);
  94. }
  95.  
  96. if(r>0 && p>0) {
  97. ans+=(double)r*p/(double)total*recurse2(r-1,s,p);
  98. }
  99.  
  100. if(p>0 && s>0) {
  101. ans+=(double)p*s/(double)total*recurse2(r,s,p-1);
  102. }
  103.  
  104. used[r][s][p]=true;
  105. state[r][s][p]=ans;
  106.  
  107. return ans;
  108. }
  109.  
  110. double recurse3(int r, int s, int p) {
  111. if(r==0 && s==0) {
  112. if(p==0) return 0.0;
  113. return 1.0;
  114. }
  115.  
  116. if(p==0) {
  117. return 0.0;
  118. }
  119.  
  120. if(used[r][s][p]) return state[r][s][p];
  121.  
  122. double ans=0.0;
  123. int total=r*s+r*p+p*s;
  124.  
  125. if(r>0 && s>0) {
  126. ans+=(double)r*s/(double)total*recurse3(r,s-1,p);
  127. }
  128.  
  129. if(r>0 && p>0) {
  130. ans+=(double)r*p/(double)total*recurse3(r-1,s,p);
  131. }
  132.  
  133. if(p>0 && s>0) {
  134. ans+=(double)p*s/(double)total*recurse3(r,s,p-1);
  135. }
  136.  
  137. used[r][s][p]=true;
  138. state[r][s][p]=ans;
  139.  
  140. return ans;
  141. }
  142.  
  143. int r,s,p;
  144.  
  145. void input() {
  146. scanf("%d %d %d", &r, &s, &p);
  147. }
  148.  
  149. void solve() {
  150. memset(used,0,sizeof(used));
  151. printf("%.15lf", recurse1(r,s,p));
  152.  
  153. memset(used,0,sizeof(used));
  154. printf(" %.15lf", recurse2(r,s,p));
  155.  
  156. memset(used,0,sizeof(used));
  157. printf(" %.15lf", recurse3(r,s,p));
  158.  
  159. printf("\n");
  160. }
  161.  
  162. int main() {
  163. input();
  164. solve();
  165.  
  166. return 0;
  167. }
  168.  
Success #stdin #stdout 0s 21584KB
stdin
Standard input is empty
stdout
0.000000000000000 0.000000000000000 0.000000000000000