結果

問題 No.219 巨大数の概算
ユーザー 明智重蔵明智重蔵
提出日時 2015-09-19 16:17:21
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 260 ms / 1,500 ms
コード長 2,102 bytes
コンパイル時間 2,355 ms
コンパイル使用メモリ 108,776 KB
実行使用メモリ 33,248 KB
最終ジャッジ日時 2023-09-25 14:51:25
合計ジャッジ時間 18,401 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 260 ms
29,312 KB
testcase_01 AC 260 ms
31,240 KB
testcase_02 AC 258 ms
31,336 KB
testcase_03 AC 257 ms
31,408 KB
testcase_04 AC 252 ms
31,220 KB
testcase_05 AC 77 ms
26,420 KB
testcase_06 AC 95 ms
28,568 KB
testcase_07 AC 77 ms
26,340 KB
testcase_08 AC 95 ms
30,700 KB
testcase_09 AC 76 ms
24,376 KB
testcase_10 AC 260 ms
29,336 KB
testcase_11 AC 258 ms
29,240 KB
testcase_12 AC 260 ms
31,296 KB
testcase_13 AC 255 ms
31,280 KB
testcase_14 AC 259 ms
29,272 KB
testcase_15 AC 260 ms
31,280 KB
testcase_16 AC 256 ms
31,304 KB
testcase_17 AC 256 ms
29,168 KB
testcase_18 AC 253 ms
29,272 KB
testcase_19 AC 257 ms
31,308 KB
testcase_20 AC 258 ms
31,292 KB
testcase_21 AC 255 ms
29,232 KB
testcase_22 AC 259 ms
29,388 KB
testcase_23 AC 256 ms
29,216 KB
testcase_24 AC 259 ms
29,240 KB
testcase_25 AC 256 ms
31,276 KB
testcase_26 AC 256 ms
31,328 KB
testcase_27 AC 258 ms
31,288 KB
testcase_28 AC 257 ms
31,276 KB
testcase_29 AC 258 ms
31,424 KB
testcase_30 AC 259 ms
29,296 KB
testcase_31 AC 257 ms
29,380 KB
testcase_32 AC 258 ms
29,208 KB
testcase_33 AC 256 ms
31,276 KB
testcase_34 AC 260 ms
29,216 KB
testcase_35 AC 255 ms
29,176 KB
testcase_36 AC 258 ms
31,440 KB
testcase_37 AC 259 ms
29,364 KB
testcase_38 AC 254 ms
29,408 KB
testcase_39 AC 256 ms
31,308 KB
testcase_40 AC 257 ms
29,348 KB
testcase_41 AC 257 ms
29,268 KB
testcase_42 AC 257 ms
31,312 KB
testcase_43 AC 256 ms
31,396 KB
testcase_44 AC 256 ms
31,308 KB
testcase_45 AC 256 ms
29,252 KB
testcase_46 AC 257 ms
29,276 KB
testcase_47 AC 259 ms
29,168 KB
testcase_48 AC 256 ms
31,416 KB
testcase_49 AC 260 ms
33,248 KB
testcase_50 AC 258 ms
29,232 KB
testcase_51 AC 76 ms
24,364 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "Input2";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2");
            WillReturn.Add("2 10");
            WillReturn.Add("9 9");
            //1 0 3
            //3 8 8
            //9の9乗は387420489です。これは9桁の数(10の8乗オーダー)であり、
            //最上位の数は3、上から2番目の数は8です。
            //上から3番目の数は7ですが、切り捨てます。 
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    struct ABInfoDef
    {
        internal int A;
        internal int B;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        var ABInfoList = new List<ABInfoDef>();
        foreach (string EachStr in InputList.Skip(1)) {
            int[] wkArr = EachStr.Split(' ').Select(X => int.Parse(X)).ToArray();
            ABInfoList.Add(new ABInfoDef() { A = wkArr[0], B = wkArr[1] });
        }

        ABInfoList.ForEach(Solve);
    }

    struct ResultInfoDef
    {
        internal double X;
        internal double Y;
        internal double Z;
    }

    static void Solve(ABInfoDef pABInfo)
    {
        double Sahen = pABInfo.B * Math.Log10(pABInfo.A);

        //丸め誤差が一番小さい値を解とする
        var ResultInfoList = new List<ResultInfoDef>();

        for (double X = 1; X <= 9; X++) {
            for (double Y = 0; Y <= 9; Y++) {
                double Z = Sahen - Math.Log10(X + Y / 10);

                ResultInfoList.Add(new ResultInfoDef() { X = X, Y = Y, Z = Z });
            }
        }

        ResultInfoDef Answer =
            ResultInfoList.OrderBy(A => Math.Abs(A.Z - Math.Truncate(A.Z))).First();
        Console.WriteLine("{0} {1} {2}", Answer.X, Answer.Y, Math.Round(Answer.Z));
    }
}
0