#include #define pr(s) std::cout << s << std::endl #define rep(n) for (int i=0;i<(n);i++) using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int k; cin >> k; if (k <= 6)cout << 1 << endl; double* dp = new double[k]; double log = 1; dp[0] = 0; while (abs(log - dp[k]) < 0.0001) { double sum = 0; for (int i = 1; i <= 6; ++i, sum = 0) { for (int j = 1; j < i; ++j) { sum += dp[k - i - j] / 6; } dp[k - i] = 1 + sum + dp[0] / 6; } for (int i = 7; i <= k; ++i, sum = 0) { for (int j = 1; j <= 6; ++j) { sum += dp[k - i - j] / 6; } dp[k - i] = 1 + sum; } log = dp[0]; } cout << dp[0]; }