結果

問題 No.25 有限小数
ユーザー ぴろずぴろず
提出日時 2014-12-19 09:26:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 5,000 ms
コード長 502 bytes
コンパイル時間 2,020 ms
コンパイル使用メモリ 72,768 KB
実行使用メモリ 55,908 KB
最終ジャッジ日時 2023-08-09 22:51:00
合計ジャッジ時間 7,227 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,504 KB
testcase_01 AC 122 ms
55,772 KB
testcase_02 AC 122 ms
55,460 KB
testcase_03 AC 121 ms
55,908 KB
testcase_04 AC 123 ms
55,904 KB
testcase_05 AC 121 ms
55,492 KB
testcase_06 AC 122 ms
55,496 KB
testcase_07 AC 124 ms
55,512 KB
testcase_08 AC 122 ms
55,812 KB
testcase_09 AC 124 ms
55,512 KB
testcase_10 AC 124 ms
55,720 KB
testcase_11 AC 124 ms
55,740 KB
testcase_12 AC 124 ms
55,484 KB
testcase_13 AC 124 ms
55,724 KB
testcase_14 AC 126 ms
55,584 KB
testcase_15 AC 122 ms
55,500 KB
testcase_16 AC 123 ms
55,540 KB
testcase_17 AC 124 ms
55,580 KB
testcase_18 AC 124 ms
55,508 KB
testcase_19 AC 124 ms
55,588 KB
testcase_20 AC 124 ms
55,784 KB
testcase_21 AC 125 ms
55,572 KB
testcase_22 AC 123 ms
55,480 KB
testcase_23 AC 123 ms
55,724 KB
testcase_24 AC 122 ms
55,728 KB
testcase_25 AC 124 ms
55,820 KB
testcase_26 AC 123 ms
55,660 KB
testcase_27 AC 126 ms
55,756 KB
testcase_28 AC 126 ms
55,440 KB
testcase_29 AC 125 ms
55,548 KB
testcase_30 AC 124 ms
55,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no025;

import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigDecimal n = new BigDecimal(sc.next());
		BigDecimal m = new BigDecimal(sc.next());
		try {
			BigDecimal ans = n.divide(m);
			ans = ans.stripTrailingZeros();
			String s = ans.unscaledValue().toString();
			System.out.println(s.charAt(s.length()-1));
		} catch (ArithmeticException e) {
			System.out.println(-1);
		}
	}
}
0