Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <string>
- #include <stack>
- #include <set>
- #include <map>
- #define pii pair <int,int>
- #define vec vector
- using namespace std;
- using ll = long long;
- using ld = long double;
- using db = double;
- void cv(vector <int> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvl(vector <ll> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvv(vector <vector <int> > &v){
- for (auto x: v) cv(x);
- cout<<"\n";
- }
- void cvb(vector <bool> v){
- for (bool x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvs(vector <string> v){
- for (auto a: v){
- cout<<a<<"\n";
- }
- }
- int n;
- string to3(int x){
- string r = "";
- while (x > 0){
- r += x % 3 + '0';
- x /= 3;
- }
- reverse(r.begin(), r.end());
- while (r.size() < n){
- r = '0' + r;
- }
- return r;
- }
- int nm(string s){
- if (s.find('.') == string::npos){
- return stoi(s) * 10;
- }
- else if (s[s.size()-1] == '0'){
- return stoi(s) * 10;
- }
- return (stoi(s)) * 10 + 5;
- }
- int h0, h1, h2;
- vector <ll> fct(25,1);
- ll C(int n, int k){
- return fct[n] / (fct[n-k] * fct[k]);
- }
- bool ok(vector <int> v){
- bool r = 1;
- if (v[v.size()-1] >= h1 && v[v.size()-1] <= h2){
- r = 1;
- }
- else return 0;
- for (int i: v){
- if (i <= 0){
- r = 0;
- break;
- }
- }
- return r;
- }
- int main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- for (int i = 1; i <= 21; ++i){
- fct[i] = fct[i-1] * i;
- }
- //cvl(fct);
- string a,b,c; cin>>a>>n>>b>>c;
- h0 = nm(a);
- h1 = nm(b);
- h2 = nm(c);
- ll ans=0;
- ll pl=1;
- for (int stay = 0; stay <= n; ++stay){
- for (int up = 0; up <= n; ++up){
- for (int down = 0;down <= n;++down){
- pl = 1;
- int stop = h0 + 5 * (up - down);
- if (stay + up + down == n && stop >= h1 && stop <= h2){
- pl *= C(n, up) * C(n - up, down);
- ans += pl;
- }
- }
- }
- }
- cout<<ans;
- }
- /*
- 2 2 2.5 3
- 100 1 95 105
- 98.0 3 99.5 100.5
- 50.5 12 51.5 81.5
- 50.5 15 51.5 81.5
- WA
- 50.5 11 51.5 81.5
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement