#include #include #include #include #include using u64 = std::uint64_t; struct rational { u64 num; u64 den; rational() : num(0), den(1) {} rational(u64 n, u64 d) : num(n), den(d) { u64 g = std::gcd(n, d); num /= g; den /= g; } friend rational operator+(const rational &l, const rational &r) { return {l.num * r.den + r.num * l.den, l.den * r.den}; } friend rational operator-(const rational &l, const rational &r) { return {l.num * r.den - r.num * l.den, l.den * r.den}; } friend rational operator*(const rational &l, const rational &r) { return {l.num * r.num, l.den * r.den}; } friend rational operator/(const rational &l, const rational &r) { return {l.num * r.den, l.den * r.num}; } }; using gate = std::array, 2>; gate concat(const gate &l, const gate &r) { gate res = {}; res[0][1] = (rational(1, 1) - l[0][0]) * r[0][1] / (r[0][0] * l[1][0] + r[0][1]); res[0][0] = rational(1, 1) - res[0][1]; res[1][0] = (rational(1, 1) - r[1][1]) * l[1][0] / (l[1][1] * r[0][1] + l[1][0]); res[1][1] = rational(1, 1) - res[1][0]; return res; } int main() { int n, k; std::cin >> n >> k; if (n == k) { std::cout << "1/1\n"; return 0; } if (k == 1) { std::cout << "0\n"; return 0; } k -= 2; std::vector a(n); for (auto &e : a) { std::cin >> e; } std::vector g(n - 2); for (int i = 0; i != n - 2; i += 1) { g[i][0][0] = g[i][1][0] = rational(a[i], a[i] + a[i + 2]); g[i][0][1] = g[i][1][1] = rational(a[i + 2], a[i] + a[i + 2]); } const auto aggregate = [&](const int l, const int r) { std::queue que; { gate t; t[0][0] = t[1][1] = rational(0, 1); t[0][1] = t[1][0] = rational(1, 1); que.push(t); } for (int i = l; i != r; i += 1) { que.push(g[i]); } while (que.size() != 1) { std::queue next; while (que.size() >= 2) { gate x = que.front(); que.pop(); gate y = que.front(); que.pop(); next.push(concat(x, y)); } if (!que.empty()) { next.push(que.front()); } que = std::move(next); } return que.front(); }; gate l = aggregate(0, k); gate r = aggregate(k, n - 2); rational ans = r[0][1] / (r[0][1] + r[0][0] * l[1][0]); std::cout << ans.num << "/" << ans.den << "\n"; return 0; }