結果

問題 No.25 有限小数
ユーザー Mcpu3Mcpu3
提出日時 2019-03-19 23:23:59
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 595 bytes
コンパイル時間 2,130 ms
コンパイル使用メモリ 73,788 KB
実行使用メモリ 56,612 KB
最終ジャッジ日時 2023-10-12 14:37:33
合計ジャッジ時間 7,588 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,020 KB
testcase_01 AC 120 ms
55,960 KB
testcase_02 AC 120 ms
56,008 KB
testcase_03 AC 122 ms
56,020 KB
testcase_04 AC 123 ms
56,456 KB
testcase_05 AC 122 ms
55,948 KB
testcase_06 AC 122 ms
55,896 KB
testcase_07 AC 121 ms
56,256 KB
testcase_08 AC 122 ms
56,128 KB
testcase_09 AC 122 ms
56,200 KB
testcase_10 AC 123 ms
56,384 KB
testcase_11 AC 119 ms
55,864 KB
testcase_12 AC 122 ms
56,512 KB
testcase_13 AC 121 ms
56,416 KB
testcase_14 AC 121 ms
56,084 KB
testcase_15 AC 119 ms
56,224 KB
testcase_16 AC 122 ms
56,384 KB
testcase_17 AC 121 ms
56,364 KB
testcase_18 AC 120 ms
56,308 KB
testcase_19 AC 119 ms
56,292 KB
testcase_20 AC 125 ms
55,876 KB
testcase_21 AC 119 ms
55,368 KB
testcase_22 WA -
testcase_23 AC 121 ms
56,284 KB
testcase_24 AC 122 ms
56,272 KB
testcase_25 AC 120 ms
56,232 KB
testcase_26 AC 120 ms
55,888 KB
testcase_27 AC 119 ms
55,972 KB
testcase_28 AC 120 ms
56,328 KB
testcase_29 AC 119 ms
53,752 KB
testcase_30 AC 123 ms
56,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong(), M = sc.nextLong();
		sc.close();
		long tmp1 = M;
		while (tmp1 % 2 == 0) tmp1 /= 2;
		while (tmp1 % 5 == 0) tmp1 /= 5;
		if (tmp1 == 1) {
			BigDecimal tmp2 = new BigDecimal(N), tmp3 = new BigDecimal(M);
			String tmp4 = tmp2.divide(tmp3).toPlainString();
			int i = tmp4.length() - 1;
			while (tmp4.charAt(i) == '0') --i;
			System.out.print(tmp4.charAt(i));
		}
		else System.out.print(-1);
	}
}
0