結果
| 問題 | No.428 小数から逃げる夢 | 
| コンテスト | |
| ユーザー |  明智重蔵 | 
| 提出日時 | 2016-10-07 19:41:07 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 78 ms / 1,000 ms | 
| コード長 | 2,743 bytes | 
| コンパイル時間 | 3,185 ms | 
| コンパイル使用メモリ | 107,136 KB | 
| 実行使用メモリ | 23,680 KB | 
| 最終ジャッジ日時 | 2024-11-21 19:52:31 | 
| 合計ジャッジ時間 | 11,997 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 100 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
class Program
{
    static string InputPattern = "InputX";
    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();
        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<string> 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\.)", ""));
    }
}
            
            
            
        