結果

問題 No.432 占い(Easy)
ユーザー taktak
提出日時 2019-06-29 05:59:30
言語 F#
(F# 4.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 917 bytes
コンパイル時間 3,628 ms
コンパイル使用メモリ 163,152 KB
実行使用メモリ 29,152 KB
最終ジャッジ日時 2023-09-14 22:58:33
合計ジャッジ時間 6,627 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
22,408 KB
testcase_01 AC 60 ms
22,364 KB
testcase_02 AC 61 ms
22,444 KB
testcase_03 AC 61 ms
22,360 KB
testcase_04 AC 62 ms
22,376 KB
testcase_05 AC 61 ms
22,356 KB
testcase_06 AC 61 ms
24,432 KB
testcase_07 AC 61 ms
22,372 KB
testcase_08 AC 61 ms
20,304 KB
testcase_09 AC 66 ms
22,524 KB
testcase_10 AC 65 ms
22,380 KB
testcase_11 AC 69 ms
28,540 KB
testcase_12 AC 115 ms
27,196 KB
testcase_13 AC 111 ms
29,152 KB
testcase_14 AC 69 ms
26,396 KB
testcase_15 AC 63 ms
24,404 KB
testcase_16 AC 62 ms
24,476 KB
testcase_17 AC 105 ms
27,136 KB
testcase_18 AC 86 ms
26,628 KB
testcase_19 AC 80 ms
28,508 KB
testcase_20 AC 70 ms
26,464 KB
testcase_21 AC 72 ms
28,616 KB
testcase_22 AC 64 ms
24,360 KB
testcase_23 AC 64 ms
22,396 KB
testcase_24 AC 66 ms
22,468 KB
testcase_25 AC 65 ms
22,404 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

module Yuki

open System

let solve ss =
    let str2Lis (str : string) =
        str.ToCharArray()
        |> Array.map (string >> int)
        |> Array.toList

    let num2Lis n =        
        let rec f acc x =
            if x >= 10 then 
                f ((x % 10) :: acc ) (x / 10)
            else
                x :: acc
        f [] n

    let horoscope (str : string) =
        let rec f =
            function
            | [] -> failwith ""
            | x :: [] -> x
            | xs ->
                let ns =
                    xs
                    |> List.pairwise
                    |> List.map ((fun (a, b) -> a + b) >> num2Lis >> List.sum)
                f ns                        
        let ns = str2Lis str
        f ns    

    ss
    |> List.map horoscope

let T = Console.ReadLine() |> int
let S = List.init T (fun _ -> Console.ReadLine())

solve S
|> List.iter Console.WriteLine
0