結果

問題 No.1464 Number Conversion
ユーザー kokatsu
提出日時 2021-11-09 19:52:27
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 468 bytes
コンパイル時間 1,360 ms
コンパイル使用メモリ 169,964 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-22 13:09:26
合計ジャッジ時間 2,201 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
/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;
    ulong num, den = 1;
    foreach (x; X) {
        if (x == '.') {
            afterDecimalPoint = true;
        }
        else {
            num = num * 10 + (x - '0');
            if (afterDecimalPoint) {
                den *= 10;
            }
        }
    }

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

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