using System; using System.Collections.Generic; using System.Collections; using System.Linq; using System.Text; using System.Numerics; using sc = Scanner; class Program { static void Main(string[] args) { Solve(); #if DEBUG System.Console.WriteLine("続行するには何かキーを押してください..."); System.Console.ReadKey(); #endif } /// /// ここでとく /// static void Solve() { int n = sc.NextInt(); double[,] mat = new double[n,n+1]; if (n >= 0 && n < 7) { Console.WriteLine(6); return; } for (int i = 0; i < n; i++) { mat[i, i] = 6.0; mat[i, n] = 6.0; } for (int i = 0; i < 6; i++) { mat[(n - 1) - i, 0] = -6.0 + 1.0 * (i + 1); } for (int i = 0; i < n; i++) { for (int j = i + 1; j < i+7 && j < n; j++) { mat[i, j] = -1.0; } } #if DEBUG Console.WriteLine("mat check"); #endif for (int i = 0; i < n; i++) { double d = mat[i,i]; for (int j = i; j < n+1; j++) { mat[i, j] /= d; // i retu wo seiki ka } for (int j = i+1; j < n; j++) { for (int k = i+1; k < n+1; k++) { mat[j, k] -= mat[j, i] * mat[i, k]; } mat[j, i] = 0; } #if DEBUG Console.WriteLine("kkk"); #endif } for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) { #if DEBUG Console.WriteLine("{0} {1}: {2} {3}",n-1-i,n-1-j,n-1-j,n); #endif mat[n-1-i,n] -= mat[n-1-i,n-1-j]*mat[n-1-j,n]; mat[n-1-i, n - 1 - j] = 0; } } Console.WriteLine(mat[0, n]); #if DEBUG Console.WriteLine("local check"); // Visual Studioのローカル変数チェック用 MainにいくとSolve内のローカル変数消えちゃう #endif } } /// /// Java風のスキャナー,自作(某最速の人を参考) 自分の実装のせいか,バグってるっぽい バグが出たらO(n^3) n=100000 でTLE /// public static class Scanner { public static string NextString() { string tmp = ""; while (true) { int readData = Console.Read(); if (readData == -1) { break; } string data = char.ConvertFromUtf32(Console.Read()); if (data == " " || data == "\n") break; tmp += readData; } return tmp; } public static string[] NextStrArray() { return Console.ReadLine().Split(' '); } public static long[] NextLongArray() { string[] s = NextStrArray(); long[] a = new long[s.Length]; for (int i = 0; i < a.Length; i++) { a[i] = long.Parse(s[i]); } return a; } public static int[] NextIntArray() { string[] s = NextStrArray(); int[] a = new int[s.Length]; for (int i = 0; i < a.Length; i++) { a[i] = int.Parse(s[i]); } return a; } public static int NextInt() { string tmp = ""; while (true) { int readData; string data; readData = Console.Read(); if (readData == -1) //EOF { break; } data = char.ConvertFromUtf32(readData); if (data == " " || data == "\n") { break; } tmp += data; } return int.Parse(tmp); } public static double NextDouble() { string tmp = ""; while (true) { string readData = char.ConvertFromUtf32(Console.Read()); if (readData == " " || readData == "\n") break; tmp += readData; } return double.Parse(tmp); } public static long NextLong() { string tmp = ""; while (true) { string readData = char.ConvertFromUtf32(Console.Read()); if (readData == " " || readData == "\n") break; tmp += readData; } return long.Parse(tmp); } public static double[] NextDoubleArray() { string[] s = NextStrArray(); double[] a = new double[s.Length]; for (int i = 0; i < a.Length; i++) { a[i] = double.Parse(s[i]); } return a; } }