using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; class Program { static string InputPattern = "InputX"; static List GetInputList() { var WillReturn = new List(); if (InputPattern == "Input1") { WillReturn.Add("1"); //0.1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991 //1倍しても値は変わりません } else if (InputPattern == "Input2") { WillReturn.Add("10"); //1.2345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910 //Dを10倍にして、小数点以下189桁までで誤差なく表示していますが、 //末尾に0がついていても正しい値です。 } else if (InputPattern == "Input3") { WillReturn.Add("14"); //1.7283950474155698398122640546882971125395367819610243852668095092337516579940822365064789307213549637792062034486276910519334761759004183246607489031731455973880216304458728701152943577185874 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List InputList = GetInputList(); string D = "0.1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991"; int N = int.Parse(InputList[0]); //整数部10桁、小数部190桁の配列 int[] NumArr = new int[10 + 190]; int UB = NumArr.GetUpperBound(0); int CurrInd = 10; foreach (char EachChar in D.Skip(2)) { NumArr[CurrInd] = EachChar - '0'; CurrInd++; } //掛け算の処理 for (int I = 0; I <= UB; I++) NumArr[I] *= N; //繰り上げ処理 for (int I = UB; 0 <= I; I--) { if (NumArr[I] > 9) { NumArr[I - 1] += NumArr[I] / 10; NumArr[I] %= 10; } } var sb = new System.Text.StringBuilder(); for (int I = 0; I <= NumArr.GetUpperBound(0); I++) { sb.Append(NumArr[I]); if (I == 9) sb.Append('.'); } Console.WriteLine(Regex.Replace(sb.ToString(), @"^0+(?=[1-9]|0\.)", "")); } }