Untitled
unknown
plain_text
4 years ago
521 B
9
Indexable
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> double lev_sums[1002]; signed main() { double res = 0; char c; int xx = 0; while ((c = getc(stdin)) != EOF) { if (c == '(') xx++; if (c == ')') xx--; if (isdigit(c)) { ungetc(c, stdin); int y; scanf("%d", &y); lev_sums[xx] += y; } } long double z = 1; for (int i = 0; i < 1001; ++i) { res += lev_sums[i] / z; z *= 2; } printf("%.2lf", res); }
Editor is loading...