T3000

Untitled

Jan 22nd, 2022
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. using ll = long long;
  5. using ld = long double;
  6.  
  7. int main()
  8. {
  9.     cout << setprecision(7);
  10.     cout << fixed;
  11.     vector<ld> z1;
  12.  
  13.     ld t, ts;
  14.     cin >> t;
  15.     ts = t;
  16.     ld a;
  17.     while (t-- > 0)
  18.     {
  19.         cin >> a;
  20.         z1.push_back(a);
  21.     }
  22.     ld s = 0;
  23.     s = z1.at(0);
  24.     ld u = 4.0, d = 5.0;
  25.     for (int i = 1; i < ts; i++)
  26.     {
  27.         s += z1.at(i) * (u / d);
  28.         u *= 4.0;
  29.         d *= 5.0;
  30.     }
  31.     s = s / 5.0;
  32.     cout << s << '\n';
  33.     ld v, sf = 0;
  34.     for (int i = 0; i < ts; i++)
  35.     {
  36.         u = 4.0;
  37.         d = 5.0;
  38.         for (int p = 0; p < ts; p++)
  39.         {
  40.             if (p != i)
  41.             {
  42.                 s = z1.at(p);
  43.                 v = p;
  44.                 break;
  45.             }
  46.         }
  47.         for (int w = 0; w < ts; w++)
  48.         {
  49.             if (w != i && w != v)
  50.             {
  51.                 s += z1.at(w) * (u / d);
  52.                 u *= 4.0;
  53.                 d *= 5.0;
  54.             }
  55.         }
  56.  
  57.         sf += s;
  58.     }
  59.     sf = sf / ts;
  60.     sf = sf / 5;
  61.     cout << sf << endl;
  62.     return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment