結果

問題 No.164 ちっちゃくないよ!!
ユーザー Nobita Gomu
提出日時 2017-09-27 17:56:22
言語 F#
(F# 4.0)
結果
AC  
実行時間 366 ms / 2,000 ms
コード長 657 bytes
コンパイル時間 19,403 ms
コンパイル使用メモリ 188,088 KB
実行使用メモリ 36,288 KB
最終ジャッジ日時 2024-11-15 17:40:31
合計ジャッジ時間 12,610 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (410 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

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