結果

問題 No.405 ローマ数字の腕時計
ユーザー guriceringuricerin
提出日時 2020-01-08 09:28:01
言語 F#
(.NET 7)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 1,562 bytes
コンパイル時間 5,778 ms
コンパイル使用メモリ 166,276 KB
実行使用メモリ 24,348 KB
最終ジャッジ日時 2023-09-21 00:43:07
合計ジャッジ時間 6,854 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
20,308 KB
testcase_01 AC 61 ms
22,368 KB
testcase_02 AC 61 ms
22,280 KB
testcase_03 AC 61 ms
24,292 KB
testcase_04 AC 62 ms
22,352 KB
testcase_05 AC 62 ms
24,172 KB
testcase_06 AC 62 ms
22,196 KB
testcase_07 AC 64 ms
20,216 KB
testcase_08 AC 65 ms
22,280 KB
testcase_09 AC 63 ms
24,236 KB
testcase_10 AC 60 ms
22,188 KB
testcase_11 AC 61 ms
22,180 KB
testcase_12 AC 63 ms
22,376 KB
testcase_13 AC 62 ms
24,324 KB
testcase_14 AC 61 ms
22,200 KB
testcase_15 AC 61 ms
20,308 KB
testcase_16 AC 61 ms
22,316 KB
testcase_17 AC 61 ms
22,344 KB
testcase_18 AC 61 ms
22,160 KB
testcase_19 AC 61 ms
24,348 KB
testcase_20 AC 61 ms
22,312 KB
testcase_21 AC 60 ms
22,236 KB
testcase_22 AC 62 ms
22,180 KB
testcase_23 AC 62 ms
20,204 KB
testcase_24 AC 62 ms
22,260 KB
testcase_25 AC 61 ms
22,360 KB
testcase_26 AC 61 ms
22,372 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

/home/judge/data/code/Main.fs(62,9): warning FS0025: Incomplete pattern matches on this expression. For example, the value '[|_; _; _|]' may indicate a case not covered by the pattern(s).

ソースコード

diff #

open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

let toInt s =
    match s with
    | "XII" -> 0
    | "I" -> 1
    | "II" -> 2
    | "III" -> 3
    | "IIII" -> 4
    | "V" -> 5
    | "VI" -> 6
    | "VII" -> 7
    | "VIII" -> 8
    | "IX" -> 9
    | "X" -> 10
    | "XI" -> 11
    | _ -> invalidArg "s" "hoge"

let toMod t =
    let sign =
        if t >= 0 then 1 else -1

    let t = abs t
    sign * (t % 12)

let toRome t =
    let t = t % 12

    let t =
        if t >= 0 then t else t + 12
    match t with
    | 0 -> "XII"
    | 1 -> "I"
    | 2 -> "II"
    | 3 -> "III"
    | 4 -> "IIII"
    | 5 -> "V"
    | 6 -> "VI"
    | 7 -> "VII"
    | 8 -> "VIII"
    | 9 -> "IX"
    | 10 -> "X"
    | 11 -> "XI"
    | _ -> invalidArg "t" "hoge"

let solve() =
    let [| s; t |] = reada string
    let t = Convert.ToInt32(t) |> toMod
    let s = s |> toInt
    s + t
    |> toRome
    |> puts


[<EntryPoint>]
let main _ =
    try
        solve()
    with e -> printfn "%s" (e.ToString())
    writer.Close()
    0 // return an integer exit code
0