結果

問題 No.164 ちっちゃくないよ!!
ユーザー Nobita GomuNobita Gomu
提出日時 2017-09-27 17:56:22
言語 F#
(F# 4.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 657 bytes
コンパイル時間 5,274 ms
コンパイル使用メモリ 159,592 KB
実行使用メモリ 25,564 KB
最終ジャッジ日時 2023-08-09 20:18:48
合計ジャッジ時間 7,300 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
23,540 KB
testcase_01 AC 106 ms
23,644 KB
testcase_02 AC 105 ms
23,496 KB
testcase_03 AC 105 ms
25,460 KB
testcase_04 AC 105 ms
23,580 KB
testcase_05 AC 109 ms
23,496 KB
testcase_06 AC 110 ms
23,632 KB
testcase_07 AC 110 ms
25,564 KB
testcase_08 AC 110 ms
23,512 KB
testcase_09 AC 109 ms
23,544 KB
testcase_10 AC 106 ms
23,560 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

let tbl =
    "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    |> Seq.mapi (fun i c -> (c, int64 i))
    |> dict

let pow (b:int64) (e:int64) =
    let rec iter (c:int64) (acc:int64) =
        match c with
        | 0L -> acc
        | _ -> iter (c-1L) (acc*b)
    iter e 1L

let convert (s:string) =
    let a = s.ToCharArray() |> Array.rev
    let b = Seq.sort a |> Seq.last |> fun c -> tbl.Item(c) + 1L

    a
    |> Seq.mapi (fun i c -> tbl.Item(c) * (pow b (int64 i)))
    |> Seq.sum

let iter n =
    seq { for _ in 1..n -> stdin.ReadLine () }
    |> Seq.map convert

let calc = int >> iter >> Seq.sort >> Seq.head

stdin.ReadLine () |> calc |> printfn "%d"
0