Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- #define ff first
- #define ss second
- #define pb push_back
- #define ppb pop_back
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- _test
- {
- int n;
- double b, h;
- cin>>n>>b>>h;
- vector<ll int> y(n);
- for(auto &e: y) cin>>e;
- double area = (b*h)/2;
- ll int prev = -1e9;
- double ans = 0;
- for(auto e: y)
- {
- if(prev+h > e)
- {
- ll int _h = prev+h - e;
- ll int _b = (_h*b)/h;
- ans -= (((_h*b))*_h);
- }
- ans += area*h*2.0;
- prev = e;
- }
- ans /= 2;
- ans /= h;
- cout<<fixed<<setprecision(10);
- cout<<ans<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment