fork(1) download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <fstream>
  4. #include <iomanip>
  5. #include <string>
  6. #include <cstdlib>
  7. #include <cstdio>
  8. #include <cstring>
  9. #include <cmath>
  10. #include <ctime>
  11. #include <climits>
  12. #include <cassert>
  13. #include <vector>
  14. #include <queue>
  15. #include <stack>
  16. #include <deque>
  17. #include <set>
  18. #include <map>
  19. #include <bitset>
  20. #include <utility>
  21. #include <algorithm>
  22.  
  23. #define forn(i, n) for (int i = 0; i < int(n); i++)
  24. #define pb push_back
  25.  
  26. using namespace std;
  27.  
  28. long double getWinProbability(long double ra, long double rb) {
  29. return 1.0 / (1.0 + pow((long double) 10.0, (rb - ra) / 400.0));
  30. }
  31.  
  32. long double aggregateRatings(vector<long double> teamRatings)
  33. {
  34. long double left = 1;
  35. long double right = 1E4;
  36.  
  37. for (int tt = 0; tt < 100; tt++) {
  38. long double r = (left + right) / 2.0;
  39.  
  40. long double rWinsProbability = 1.0;
  41. forn(i, teamRatings.size())
  42. rWinsProbability *= getWinProbability(r, teamRatings[i]);
  43.  
  44. long double rating = log10(1 / (rWinsProbability) - 1) * 400 + r;
  45.  
  46. if (rating > r)
  47. left = r;
  48. else
  49. right = r;
  50. }
  51.  
  52. return (left + right) / 2.0;
  53. }
  54.  
  55. int main(int argc, char* argv[])
  56. {
  57. vector<long double> SpbSU_Base;
  58. SpbSU_Base.pb(2765); // aid
  59. SpbSU_Base.pb(2739); // ershov.stanislav
  60. SpbSU_Base.pb(2551); // -XraY-
  61.  
  62. vector<long double> LatviaU;
  63. LatviaU.pb(2904); //Alex_2oo8
  64. LatviaU.pb(2148); //Pakalns
  65. LatviaU.pb(1919); //A_Le_K
  66.  
  67. vector<long double> HSE1;
  68. HSE1.pb(2998); //Um_nik
  69. HSE1.pb(2055); //WYOCMWYH
  70. // HSE1.pb(???); //Vadim Kalashnikov
  71.  
  72.  
  73. //@jinotega3000
  74. vector<long double> Jinotega;
  75. Jinotega.pb(2741); //zemen
  76. Jinotega.pb(2721); //ifsmirnov
  77. Jinotega.pb(2506); //Arterm
  78.  
  79. vector<long double> ITMO1;
  80. ITMO1.pb(2762); //izban
  81. ITMO1.pb(2550); //enot.1.10
  82. ITMO1.pb(2545); //Belonogov
  83.  
  84.  
  85. vector<long double> PermSU;
  86. PermSU.pb(2650); //I_love_Tanya_Romanova
  87. PermSU.pb(2576); //mmaxio
  88. PermSU.pb(2411); //KuchumovIlya
  89.  
  90. vector<long double> SaratovSU;
  91. SaratovSU.pb(2537); //HellKitsune
  92. SaratovSU.pb(2485); //dans
  93. SaratovSU.pb(2349); //IlyaLos
  94.  
  95. vector<long double> ITMO2;
  96. ITMO2.pb(2450); //BudAlNik
  97. ITMO2.pb(2422); //YakutovDmitriy
  98. ITMO2.pb(2413); //SpyCheese
  99.  
  100. vector<long double> BSUIR;
  101. BSUIR.pb(2571); //netman
  102. BSUIR.pb(2318); //andrew.volchek
  103. BSUIR.pb(2247); //teleport
  104.  
  105. vector<long double> SpbSU3;
  106. SpbSU3.pb(2474); //Kaban-5
  107. SpbSU3.pb(2431); //pavel.savchenkov
  108. SpbSU3.pb(2226); // tunyash
  109.  
  110.  
  111. vector<long double> UralFU;
  112. UralFU.pb(2438); //Tinsane
  113. UralFU.pb(2363); //kb.
  114. UralFU.pb(2262); // KungA
  115.  
  116.  
  117. // 2900+
  118.  
  119. printf("HSE#1 %.10lf\n", double(aggregateRatings(HSE1)));
  120. printf("SpbSU Base %.10lf\n", double(aggregateRatings(SpbSU_Base)));
  121. printf("Jinotega %.10lf\n", double(aggregateRatings(Jinotega)));
  122. printf("Latvia U 1 %.10lf\n", double(aggregateRatings(LatviaU)));
  123.  
  124. // 2800+
  125.  
  126. printf("ITMO 1 %.10lf\n", double(aggregateRatings(ITMO1)));
  127. printf("PermSU %.10lf\n", double(aggregateRatings(PermSU)));
  128.  
  129. // 2700+
  130.  
  131. printf("Saratov SU %.10lf\n", double(aggregateRatings(SaratovSU)));
  132.  
  133. // 2600+
  134.  
  135. printf("ITMO 2 %.10lf\n", double(aggregateRatings(ITMO2)));
  136. printf("B SUIR %.10lf\n", double(aggregateRatings(BSUIR)));
  137. printf("SpbSU 3 %.10lf\n", double(aggregateRatings(SpbSU3)));
  138.  
  139. // 2500+
  140.  
  141. printf("UralFU Ch. %.10lf\n", double(aggregateRatings(UralFU)));
  142.  
  143.  
  144. return 0;
  145. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
HSE#1      2999.5121561847
SpbSU Base 2937.9237191871
Jinotega   2913.1504943568
Latvia U 1 2909.5113778587
ITMO 1     2877.7099709162
PermSU     2800.9196640221
Saratov SU 2704.5859363758
ITMO 2     2662.9688777241
B SUIR     2658.7313493079
SpbSU 3    2635.0951672458
UralFU Ch. 2599.9579123698