結果
問題 | No.219 巨大数の概算 |
ユーザー |
![]() |
提出日時 | 2015-05-30 14:03:01 |
言語 | Java (openjdk 23) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,042 bytes |
コンパイル時間 | 3,819 ms |
コンパイル使用メモリ | 78,216 KB |
実行使用メモリ | 46,540 KB |
最終ジャッジ日時 | 2024-10-07 17:04:07 |
合計ジャッジ時間 | 24,466 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 49 WA * 2 |
ソースコード
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; } }