Advertisement
Korotkodul

Untitled

Mar 10th, 2022
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. #include <queue>
  5. #include <algorithm>
  6. #include <string>
  7. #include <stack>
  8. #include <set>
  9. #include <map>
  10. #define pii pair <int,int>
  11. #define vec vector
  12. using namespace std;
  13. using ll = long long;
  14. using ld = long double;
  15. using db = double;
  16. void cv(vector <int> &v){
  17.     for (auto x: v) cout<<x<<' ';
  18.     cout<<"\n";
  19. }
  20.  
  21. void cvl(vector <ll> &v){
  22.     for (auto x: v) cout<<x<<' ';
  23.     cout<<"\n";
  24. }
  25.  
  26.  
  27. void cvv(vector <vector <int> > &v){
  28.     for (auto x: v) cv(x);
  29.     cout<<"\n";
  30. }
  31.  
  32. void cvb(vector <bool> v){
  33.     for (bool x: v) cout<<x<<' ';
  34.     cout<<"\n";
  35. }
  36.  
  37. void cvs(vector <string>  v){
  38.     for (auto a: v){
  39.         cout<<a<<"\n";
  40.     }
  41. }
  42. int n;
  43.  
  44. string to3(int x){
  45.     string r = "";
  46.     while (x > 0){
  47.         r += x % 3 + '0';
  48.         x /= 3;
  49.     }
  50.     reverse(r.begin(), r.end());
  51.     while (r.size() < n){
  52.         r = '0' + r;
  53.     }
  54.     return r;
  55. }
  56.  
  57. int nm(string s){
  58.     if (s.find('.') == string::npos){
  59.         return stoi(s) * 10;
  60.     }
  61.     else if (s[s.size()-1] == '0'){
  62.         return stoi(s) * 10;
  63.     }
  64.     return (stoi(s)) * 10 + 5;
  65. }
  66.  
  67.  
  68.  
  69. int  h0, h1, h2;
  70.  
  71.  
  72. vector <ll> fct(25,1);
  73.  
  74.  
  75. ll C(int n, int k){
  76.     return fct[n] / (fct[n-k] * fct[k]);
  77. }
  78.  
  79. bool ok(vector <int> v){
  80.     bool r = 1;
  81.     if (v[v.size()-1] >= h1 && v[v.size()-1] <= h2){
  82.         r = 1;
  83.     }
  84.     else return 0;
  85.     for (int i: v){
  86.         if (i <= 0){
  87.             r = 0;
  88.             break;
  89.         }
  90.     }
  91.     return r;
  92. }
  93.  
  94. int main()
  95. {
  96.     ios::sync_with_stdio(0);
  97.     cin.tie(0);
  98.     cout.tie(0);
  99.     for (int i = 1; i <= 21; ++i){
  100.         fct[i] = fct[i-1] * i;
  101.     }
  102.     //cvl(fct);
  103.      string a,b,c; cin>>a>>n>>b>>c;
  104.      h0 = nm(a);
  105.      h1 = nm(b);
  106.      h2 = nm(c);
  107.      ll ans=0;
  108.      ll pl=1;
  109.      for (int stay = 0; stay <= n; ++stay){
  110.         for (int up = 0; up <= n; ++up){
  111.             for (int down = 0;down <= n;++down){
  112.                 pl = 1;
  113.                 int stop = h0 + 5 * (up - down);
  114.                 if (stay + up + down == n &&  stop >= h1 && stop <= h2){
  115.                     pl *= C(n, up) * C(n - up, down);
  116.  
  117.                     ans += pl;
  118.                 }
  119.  
  120.             }
  121.         }
  122.      }
  123.      cout<<ans;
  124.  
  125. }
  126. /*
  127. 2 2 2.5 3
  128.  
  129. 100 1 95 105
  130.  
  131. 98.0 3 99.5 100.5
  132.  
  133. 50.5 12 51.5 81.5
  134.  
  135.  
  136. 50.5 15 51.5 81.5
  137. WA
  138.  
  139.  
  140. 50.5 11 51.5 81.5
  141. */
  142.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement