結果

問題 No.219 巨大数の概算
ユーザー mban
提出日時 2017-01-12 16:11:13
言語 C#
(mono 4.8.0)
結果
AC  
実行時間 121 ms
コード長 2518 Byte
コンパイル時間 1694 ms
使用メモリ 1496 KB

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
1.txt AC 101 ms
1484 KB
2.txt AC 100 ms
1492 KB
3.txt AC 99 ms
1492 KB
challenge01.txt AC 94 ms
1488 KB
challenge02.txt AC 28 ms
1488 KB
challenge03.txt AC 35 ms
1496 KB
challenge04.txt AC 28 ms
1488 KB
challenge05.txt AC 35 ms
1492 KB
sample.txt AC 28 ms
1492 KB
system_test1.txt AC 110 ms
1488 KB
system_test2.txt AC 100 ms
1492 KB
system_test3.txt AC 105 ms
1492 KB
system_test4.txt AC 104 ms
1496 KB
system_test5.txt AC 103 ms
1492 KB
system_test6.txt AC 99 ms
1488 KB
system_test7.txt AC 100 ms
1492 KB
system_test8.txt AC 97 ms
1488 KB
system_test9.txt AC 98 ms
1492 KB
system_test10.txt AC 103 ms
1488 KB
system_test11.txt AC 97 ms
1496 KB
system_test12.txt AC 105 ms
1488 KB
system_test13.txt AC 103 ms
1488 KB
system_test14.txt AC 106 ms
1488 KB
system_test15.txt AC 101 ms
1496 KB
system_test16.txt AC 102 ms
1492 KB
system_test17.txt AC 104 ms
1492 KB
system_test18.txt AC 102 ms
1488 KB
system_test19.txt AC 100 ms
1492 KB
system_test20.txt AC 99 ms
1488 KB
system_test21.txt AC 101 ms
1488 KB
system_test22.txt AC 100 ms
1488 KB
system_test23.txt AC 95 ms
1488 KB
system_test24.txt AC 98 ms
1492 KB
system_test25.txt AC 98 ms
1492 KB
system_test26.txt AC 100 ms
1488 KB
system_test27.txt AC 98 ms
1488 KB
system_test28.txt AC 104 ms
1492 KB
system_test29.txt AC 96 ms
1492 KB
system_test30.txt AC 96 ms
1488 KB
system_test31.txt AC 100 ms
1492 KB
system_test32.txt AC 102 ms
1488 KB
system_test33.txt AC 120 ms
1492 KB
system_test34.txt AC 121 ms
1488 KB
system_test35.txt AC 100 ms
1488 KB
system_test36.txt AC 100 ms
1492 KB
system_test37.txt AC 100 ms
1488 KB
system_test38.txt AC 104 ms
1488 KB
system_test39.txt AC 103 ms
1492 KB
system_test40.txt AC 98 ms
1492 KB
system_test41.txt AC 99 ms
1492 KB
system_test42.txt AC 30 ms
1484 KB
テストケース一括ダウンロード

ソースコード

diff #
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;

class Program
{
    static private Magatro M = new Magatro();
    static private void Main(string[]args)
    {
        M.Scan();
        M.Solve();
    }
}

public class Scanner
{
    private string[] S;
    private int Index;
    private char Separator;

    public Scanner(char separator = ' ')
    {
        Index = 0;
        Separator = separator;
    }

    private string[] Line()
    {
        return Console.ReadLine().Split(Separator);
    }

    public string Next()
    {
        string result;
        if (S == null || Index >= S.Length)
        {
            S = Line();
            Index = 0;
        }
        result = S[Index];
        Index++;
        return result;
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
}

public class Magatro
{
    private int N;
    private Scanner Sc = new Scanner();
    private double[,] Log = new double[10, 10];
    public void Scan()
    {
        N = Sc.NextInt();
    }
    private void Start()
    {
        for(int i = 1; i < 10; i++)
        {
            for(int j = 0; j < 10; j++)
            {
                Log[i, j] = Math.Log10(i + (double)j / 10);
            }
        }
    }
    public void Solve()
    {
        Start();
        for (int i = 0; i < N; i++)
        {
            int a = Sc.NextInt();
            int b = Sc.NextInt();
            Console.WriteLine(Anser(a, b));
        }
    }
    private string Anser(int a,int b)
    {
        double bLoga = Math.Log10(a) * b;
        long  Z;
        Z = (long)bLoga;
        double shousu = bLoga - Z;

        return string.Join(" ", Check(shousu), Z);
    }
    private string Check(double shousu)
    {
        for(int i = 1; i < 10; i++)
        {
            for(int j = 0; j < 10; j++)
            {
                if (Log[i, j] > shousu)
                {
                    if (j == 0)
                    {
                        return string.Join(" ", i - 1, 9);
                    }
                    else
                    {
                        return string.Join(" ", i, j - 1);
                    }
                }
            }
        }
        return "9 9";
    }
}
0