結果

問題 No.1464 Number Conversion
ユーザー kokatsu
提出日時 2021-11-09 19:48:14
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 460 bytes
コンパイル時間 1,615 ms
コンパイル使用メモリ 170,896 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-22 13:09:16
合計ジャッジ時間 2,718 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!ulong.gcdImpl`

ソースコード

diff #

import std;

void main() {
    string X = readln.chomp;

    bool afterDecimalPoint;
    long num, den = 1;
    foreach (x; X) {
        if (x == '.') {
            afterDecimalPoint = true;
        }
        else {
            num = num * 10 + (x - '0');
            if (afterDecimalPoint) {
                den *= 10;
            }
        }
    }

    long g = gcd(num, den);
    if (g > 0) {
        num /= g, den /= g;
    }

    writeln(num, "/", den);
}
0