結果

問題 No.1464 Number Conversion
ユーザー tentententen
提出日時 2022-08-05 09:00:22
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,280 bytes
コンパイル時間 2,136 ms
コンパイル使用メモリ 74,700 KB
実行使用メモリ 58,824 KB
最終ジャッジ日時 2023-10-13 07:20:00
合計ジャッジ時間 6,919 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
55,980 KB
testcase_01 AC 113 ms
55,856 KB
testcase_02 AC 112 ms
55,904 KB
testcase_03 AC 112 ms
55,988 KB
testcase_04 AC 112 ms
56,304 KB
testcase_05 AC 112 ms
56,108 KB
testcase_06 AC 113 ms
55,704 KB
testcase_07 AC 114 ms
55,840 KB
testcase_08 WA -
testcase_09 AC 112 ms
56,360 KB
testcase_10 AC 114 ms
56,064 KB
testcase_11 AC 112 ms
56,348 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 114 ms
55,840 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 111 ms
56,080 KB
testcase_21 AC 112 ms
56,288 KB
testcase_22 AC 115 ms
56,300 KB
testcase_23 AC 112 ms
56,076 KB
testcase_24 AC 114 ms
55,724 KB
testcase_25 AC 110 ms
56,120 KB
testcase_26 AC 110 ms
55,852 KB
testcase_27 AC 111 ms
56,472 KB
testcase_28 AC 110 ms
56,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        double d = sc.nextDouble();
        long base = 1;
        while ((long)d != d) {
            d *= 10;
            base *= 10;
        }
        long n = (long)d;
        long gcd = getGCD(base, n);
        System.out.printf("%d/%d\n", n / gcd, base / gcd);
    }
    
    static long getGCD(long x, long y) {
        if (y == 0) {
            return x;
        } else {
            return getGCD(y, x % y);
        }
    }
}

class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0