結果

問題 No.1464 Number Conversion
ユーザー ks2mks2m
提出日時 2021-04-02 21:33:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 168 ms / 2,000 ms
コード長 475 bytes
コンパイル時間 3,494 ms
コンパイル使用メモリ 75,232 KB
実行使用メモリ 59,024 KB
最終ジャッジ日時 2023-08-25 11:35:20
合計ジャッジ時間 9,031 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 156 ms
56,980 KB
testcase_01 AC 158 ms
57,324 KB
testcase_02 AC 165 ms
57,264 KB
testcase_03 AC 168 ms
56,760 KB
testcase_04 AC 164 ms
56,884 KB
testcase_05 AC 162 ms
56,896 KB
testcase_06 AC 161 ms
57,492 KB
testcase_07 AC 155 ms
57,444 KB
testcase_08 AC 155 ms
56,860 KB
testcase_09 AC 154 ms
57,200 KB
testcase_10 AC 150 ms
57,352 KB
testcase_11 AC 156 ms
57,408 KB
testcase_12 AC 157 ms
56,532 KB
testcase_13 AC 151 ms
59,024 KB
testcase_14 AC 157 ms
57,004 KB
testcase_15 AC 168 ms
57,524 KB
testcase_16 AC 157 ms
57,132 KB
testcase_17 AC 160 ms
56,784 KB
testcase_18 AC 154 ms
57,232 KB
testcase_19 AC 158 ms
56,804 KB
testcase_20 AC 154 ms
56,964 KB
testcase_21 AC 156 ms
57,000 KB
testcase_22 AC 156 ms
57,508 KB
testcase_23 AC 149 ms
56,816 KB
testcase_24 AC 155 ms
57,376 KB
testcase_25 AC 154 ms
57,232 KB
testcase_26 AC 156 ms
57,100 KB
testcase_27 AC 157 ms
56,988 KB
testcase_28 AC 155 ms
57,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		BigDecimal x = sc.nextBigDecimal();
		sc.close();

		long m = 1000000000;
		x = x.multiply(BigDecimal.valueOf(m));
		long n = x.longValue();
		long g = gcd(n, m);
		n /= g;
		m /= g;
		System.out.println(n + "/" + m);
	}

	static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}
}
0