結果

問題 No.219 巨大数の概算
ユーザー mobius_bkstmobius_bkst
提出日時 2015-05-30 14:03:01
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,042 bytes
コンパイル時間 3,549 ms
コンパイル使用メモリ 77,348 KB
実行使用メモリ 46,580 KB
最終ジャッジ日時 2024-04-16 17:58:33
合計ジャッジ時間 24,662 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 384 ms
46,148 KB
testcase_01 AC 373 ms
46,324 KB
testcase_02 AC 373 ms
46,212 KB
testcase_03 WA -
testcase_04 AC 370 ms
46,168 KB
testcase_05 AC 95 ms
40,072 KB
testcase_06 AC 190 ms
42,108 KB
testcase_07 AC 91 ms
40,320 KB
testcase_08 AC 188 ms
42,316 KB
testcase_09 AC 93 ms
40,476 KB
testcase_10 AC 367 ms
45,936 KB
testcase_11 AC 365 ms
46,100 KB
testcase_12 AC 364 ms
46,264 KB
testcase_13 AC 381 ms
46,120 KB
testcase_14 AC 371 ms
46,364 KB
testcase_15 AC 366 ms
45,940 KB
testcase_16 AC 366 ms
46,132 KB
testcase_17 AC 370 ms
46,332 KB
testcase_18 AC 375 ms
46,392 KB
testcase_19 AC 370 ms
46,444 KB
testcase_20 AC 365 ms
46,132 KB
testcase_21 AC 372 ms
46,236 KB
testcase_22 AC 373 ms
46,220 KB
testcase_23 AC 385 ms
46,324 KB
testcase_24 AC 382 ms
46,112 KB
testcase_25 WA -
testcase_26 AC 367 ms
46,116 KB
testcase_27 AC 372 ms
46,092 KB
testcase_28 AC 375 ms
46,432 KB
testcase_29 AC 371 ms
46,272 KB
testcase_30 AC 372 ms
46,580 KB
testcase_31 AC 361 ms
46,132 KB
testcase_32 AC 376 ms
46,316 KB
testcase_33 AC 372 ms
46,164 KB
testcase_34 AC 372 ms
46,128 KB
testcase_35 AC 368 ms
46,100 KB
testcase_36 AC 378 ms
46,084 KB
testcase_37 AC 368 ms
46,248 KB
testcase_38 AC 364 ms
46,284 KB
testcase_39 AC 373 ms
46,336 KB
testcase_40 AC 367 ms
46,220 KB
testcase_41 AC 368 ms
46,236 KB
testcase_42 AC 365 ms
46,420 KB
testcase_43 AC 378 ms
46,400 KB
testcase_44 AC 365 ms
46,228 KB
testcase_45 AC 361 ms
46,356 KB
testcase_46 AC 371 ms
46,400 KB
testcase_47 AC 367 ms
46,140 KB
testcase_48 AC 375 ms
46,132 KB
testcase_49 AC 366 ms
46,420 KB
testcase_50 AC 362 ms
46,296 KB
testcase_51 AC 93 ms
39,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class No219 {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(
                    System.in));

            double[] logarithmTable = createLogarithmTable();

            int N = Integer.parseInt(br.readLine());
            for (int i = 0; i < N; i++) {
                String[] a = br.readLine().split(" ");

                double A = Double.parseDouble(a[0]);
                double B = Double.parseDouble(a[1]);

                double ans = B * Math.log10(A);
                long Z = (long) Math.floor(ans);
                double decimalPart = ans - Z;
                int high = 100;
                int low = 10;
                int mid = 0;
                while (low < high) {
                    mid = (high + low) / 2;
                    if (decimalPart == logarithmTable[mid]) {
                        break;
                    } else if (decimalPart < logarithmTable[mid]) {
                        high = mid;
                    } else {
                        low = mid + 1;
                    }
                }
                double XY = mid * 0.1;
                int X = (int) Math.floor(XY);
                int Y = (int) ((XY - X) * 10);
                System.out.println(X + " " + Y + " " + Z);

            }

        } catch (Exception e) {
            System.err.println("Error:" + e.getMessage());
        }
    }

    // static double[][] createLogarithmTable() {
    // double[][] logarithmTable = new double[10][10];
    // for (int i = 1; i < 10; i++) {
    // for (int j = 0; j < 10; j++) {
    // logarithmTable[i][j] = Math.log10(i + j * 0.1);
    // }
    // }
    // return logarithmTable;
    // }
    static double[] createLogarithmTable() {
        double[] logarithmTable = new double[100];
        for (int i = 10; i < 100; i++) {
            logarithmTable[i] = Math.log10(i * 0.1);
        }
        return logarithmTable;
    }

}
0