#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define endl '\n' #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end()) typedef long long ll; typedef long double ld; typedef pair P; typedef complex comp; typedef vector< vector > matrix; struct pairhash { public: template size_t operator()(const pair &x) const { size_t seed = hash()(x.first); return hash()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2); } }; const int inf = 1e9 + 9; const ll mod = 1e9 + 7; const double eps = 1e-8; const double pi = acos(-1); int K; // if index size = 0, LU decomposition failed. vector LUdecomposition(matrix& A) { const int n = A.size(); vector index(n); for (int i = 0; i < n; i++) index[i] = i; for (int i = 0; i < n; i++) { int pivot = i; for (int j = i+1; j < n; j++) if (abs(A[j][i]) > abs(A[pivot][i])) pivot = j; swap(A[pivot], A[i]); swap(index[pivot], index[i]); // failed if (abs(A[i][i]) < eps) { index.clear(); return index; } for (int j = i+1; j < n; j++) { A[j][i] /= A[i][i]; for (int k = i+1; k < n; k++) A[j][k] -= A[i][k] * A[j][i]; } } return index; } vector solve_simuleq(matrix A, vector b) { vector index = LUdecomposition(A); if (index.size() == 0) return vector(0); int n = A.size(); vector c(n), tmp(n), res(n); for (int i = 0; i < n; i++) { c[i] = b[index[i]]; for (int j = 0; j < i; j++) c[i] -= A[i][j] * c[j]; } for (int i = n-1; i >= 0; i--) { tmp[i] = c[i]; for (int j = n-1; j > i; j--) tmp[i] -= A[i][j] * tmp[j]; tmp[i] /= A[i][i]; } for (int i = 0; i < n; i++) res[index[i]] = tmp[i]; return res; } ld solve() { matrix A(K, vector(K, 0.0)); vector b(K); for (int i = 0; i < K; i++) { A[i][i] = 1.0; for (int j = 1; j <= 6; j++) { int k = i + j; if (k < K) A[i][k] -= 1.0/6.0; else if (k > K) A[i][0] -= 1.0/6.0; } } for (int i = 0; i < K; i++) b[i] = 1.0; return (solve_simuleq(A, b))[0]; } void input() { cin >> K; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); input(); cout << solve() << endl; }