fork download
  1. #include <vector>
  2. #include <map>
  3. #include <unordered_map>
  4. #include <set>
  5. #include <unordered_set>
  6. #include <queue>
  7. #include <stack>
  8. #include <algorithm>
  9. #include <iostream>
  10. #include <string>
  11. #include <cstring>
  12. #include <cstdlib>
  13. #include <cstdio>
  14. #include <cmath>
  15. #include <climits>
  16. #include <cctype>
  17. #include <iomanip>
  18. #include <bitset>
  19. #include <list>
  20. #include <deque>
  21. #include <utility>
  22. #include <functional>
  23. #include <cassert>
  24. #include <complex>
  25.  
  26. using namespace std;
  27.  
  28. #define all(a) (a).begin(), (a).end()
  29. #define ms(a, b) memset(a, b, sizeof(a))
  30. #define mc(a, b) memcpy(a, b, sizeof(b))
  31. #define mp make_pair
  32. #define mt make_tuple
  33. #define pb push_back
  34. #define eb emplace_back
  35. #define fore(it, a) for (auto it = (a).begin(), it##_ = (a).end(); it != it##_; ++it)
  36. #define f0r(i, a) for (int i = 0, i##_ = (a); i < i##_; ++i)
  37. #define debug(args...) do {cerr << #args << ": "; dbg,args; cerr << endl;} while(0)
  38. #define read(type, args...) type args; rdr,args;
  39. #define fi first
  40. #define se second
  41. #define bit_no __builtin_popcount
  42. #define left(a) (2*(a))
  43. #define right(a) (2*(a)+1)
  44. #define mid(left, right) (((left)+(right))/2+1)
  45. #define PI acos(-1)
  46. #define X fi
  47. #define Y se
  48.  
  49. typedef long long ll;
  50. typedef long double ld;
  51. typedef unsigned long long ull;
  52. typedef vector<int> vi;
  53. typedef vector<vi> vvi;
  54. typedef pair<int, int> ii;
  55. typedef tuple<int, int, int> iii;
  56. typedef vector<ii> vii;
  57. typedef vector<iii> viii;
  58.  
  59. template<typename T>
  60. using min_pq = priority_queue<T, vector<T>, greater<T>>;
  61.  
  62. template<typename T>
  63. using max_pq = priority_queue<T>;
  64.  
  65. const int inf = 2e9+5;
  66. const ll l_inf = 2e18+5;
  67. const int mod_v = 1e9+7;
  68. const int max_n = 5e5+5;
  69.  
  70. const int dx[4] = {1, 0, -1, 0};
  71. const int dy[4] = {0, 1, 0, -1};
  72.  
  73. template<typename T>
  74. T gcd(T a, T b)
  75. {
  76. while (b) {
  77. T temp = a % b;
  78. a = b;
  79. b = temp;
  80. }
  81. return a;
  82. }
  83.  
  84. template<typename T>
  85. tuple<T, T, T> egcd(T a, T b)
  86. {
  87. T x1 = 1, x2 = 0, y1 = 0, y2 = 1;
  88. while (b) {
  89. T q = a / b, r = a % b;
  90. T new_x = x1 - q*x2, new_y = y1 - q*y2;
  91. x1 = x2, y1 = y2, x2 = new_x, y2 = new_y;
  92. a = b, b = r;
  93. }
  94. return make_tuple(a, x1, y1);
  95. }
  96.  
  97. inline ll lcm(ll a, ll b)
  98. {
  99. return a*b/gcd(a, b);
  100. }
  101.  
  102. template<typename T>
  103. inline T mod(T a, T b = mod_v)
  104. {
  105. return (a % b + b) % b;
  106. }
  107.  
  108. template<typename T>
  109. inline T mod_inv(T a, T b = mod_v)
  110. {
  111. return mod(get<1>(egcd(a, b)), b);
  112. }
  113.  
  114. template<typename T>
  115. inline T sum(T a, T b, T m = mod_v)
  116. {
  117. return mod(mod(a, m) + mod(b, m), m);
  118. }
  119.  
  120. template<typename T>
  121. inline T difference(T a, T b, T m = mod_v)
  122. {
  123. return mod(mod(a, m) - mod(b, m), m);
  124. }
  125.  
  126. inline ll product(ll a, ll b, ll m = mod_v)
  127. {
  128. return mod(mod(a, m) * mod(b, m), m);
  129. }
  130.  
  131. inline ll quotient(ll a, ll b, ll m = mod_v)
  132. {
  133. return mod(mod(a, m) * mod_inv(b, m), m);
  134. }
  135.  
  136. template<typename T,typename T2>
  137. ostream& operator<< (ostream &s, const pair<T,T2> &p) {return s << p.fi << ' ' << p.se << ' ';}
  138.  
  139. template<typename T,typename T2>
  140. istream& operator>> (istream &s, pair<T,T2> &p) {return s >> p.fi >> p.se;}
  141.  
  142. template<typename T>
  143. ostream& operator<< (ostream &s, const vector<T> &v) {for (auto it: v) s << it << ' '; return s;}
  144.  
  145. template<typename T>
  146. istream& operator>> (istream &s, vector<T> &v) {fore (it, v) s >> *it; return s;}
  147.  
  148. template<typename T>
  149. void read_range(T beg, T end)
  150. {
  151. while (beg != end)
  152. cin >> *beg++;
  153. }
  154.  
  155. template<typename T>
  156. void print_range(T beg, T end)
  157. {
  158. while (beg != end)
  159. cout << *beg++ << ' ';
  160. }
  161.  
  162. struct reader
  163. {
  164. template<typename T>
  165. reader& operator, (T &v)
  166. {
  167. cin >> v;
  168. return *this;
  169. }
  170. } rdr;
  171.  
  172. struct debugger
  173. {
  174. template<typename T>
  175. debugger& operator, (const T &v)
  176. {
  177. cerr << v << ", ";
  178. return *this;
  179. }
  180. } dbg;
  181.  
  182. /***************************************************************
  183. ----------------------------------------------------------------
  184. ----------------------------------------------------------------
  185. ***************************************************************/
  186.  
  187. inline int v(char ch)
  188. {
  189. return (ch == 'I' or ch == 'E' or ch == 'A' or ch == 'O' or ch == 'U' or ch == 'Y');
  190. }
  191.  
  192. string s, sz;
  193. double ar[max_n];
  194. double pre[max_n];
  195.  
  196. int main()
  197. {
  198. ios_base::sync_with_stdio(false);
  199.  
  200. cin >> s;
  201. int sz = s.size();
  202.  
  203. for (int i = 1; i <= sz; ++i) {
  204. ar[i] = 1./i;
  205. }
  206. for (int i = sz; i >= 1; --i) {
  207. pre[i] = pre[i+1] + ar[i];
  208. }
  209.  
  210. double res = 0;
  211. double val = 0;
  212. for (int i = 0; i < sz/2; ++i) {
  213. val += pre[i+1] - pre[sz+1-i];
  214. res += ((v(s[i]) + v(s[sz-1-i])) * val);
  215. }
  216. if (sz % 2) {
  217. val += pre[sz/2+1] - pre[sz+1-sz/2];
  218. res += v(s[sz/2]) * val;
  219. }
  220.  
  221. cout << setprecision(6) << fixed << res;
  222.  
  223. return 0;
  224. }
Success #stdin #stdout 0s 11088KB
stdin
IEAIAIO
stdout
28.000000