結果

問題 No.428 小数から逃げる夢
ユーザー xsd
提出日時 2020-07-08 23:27:34
言語 OCaml
(5.2.1)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 699 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 21,576 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-09 01:48:27
合計ジャッジ時間 3,044 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 100
権限があれば一括ダウンロードができます

ソースコード

diff #

Scanf.scanf "%d" (fun n ->
    let a = Array.make 192 0 in

    let rec loop i j =
        if i < 10 then (a.(j) <- i; loop (i + 1) (j + 1)) else
        if i < 100 then (
            a.(j) <- i / 10;
            a.(j + 1) <- i mod 10;
            loop (i + 1) (j + 2)
        ) else (
            a.(j) <- 1
        )
    in
    loop 1 2;

    let b = Array.make 192 0 in

    let rec loop i carry =
        if i >= 0 then
            let c = a.(i) * n + carry in
            let () = b.(i) <- c mod 10 in
            loop (i - 1) (c / 10)
    in
    loop 191 0;
    Printf.printf "%d." (b.(0) * 10 + b.(1));
    for i = 2 to 191 do
        Printf.printf "%d" b.(i)
    done;
    print_newline ()
)
0