結果
問題 | No.49 算数の宿題 |
ユーザー | guricerin |
提出日時 | 2020-02-06 11:10:10 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 62 ms / 5,000 ms |
コード長 | 4,053 bytes |
コンパイル時間 | 4,804 ms |
コンパイル使用メモリ | 165,568 KB |
実行使用メモリ | 24,348 KB |
最終ジャッジ日時 | 2023-08-24 17:45:16 |
合計ジャッジ時間 | 6,116 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 60 ms
22,124 KB |
testcase_01 | AC | 61 ms
24,348 KB |
testcase_02 | AC | 61 ms
22,236 KB |
testcase_03 | AC | 62 ms
24,316 KB |
testcase_04 | AC | 62 ms
22,192 KB |
testcase_05 | AC | 62 ms
22,264 KB |
testcase_06 | AC | 62 ms
22,268 KB |
testcase_07 | AC | 62 ms
24,212 KB |
testcase_08 | AC | 62 ms
22,276 KB |
testcase_09 | AC | 61 ms
22,172 KB |
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0 Copyright (c) Microsoft Corporation. All Rights Reserved.
ソースコード
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 // ----------------------------------------------------------------------------------------------------- // / ` 、 感謝するぜ お前と出会えた // / ノノ ヽ // , ニニ彡'⌒ /`ヽ これまでの 全てに // ' ニミ ニニ彡 〈rう├--ミ // { { ニミ } j j jノx'ィイく }し{\ `丶、___/ニニニ // j_ニニミV ハレノ x<⌒ヽ V ヘ \ \ニニニニニニニ // {xミミー'ヾ(、ル( 厶tァァく⌒ヾ} )ハ::::::. \ニニニニニニ // 彡ィ'">tァ} \(`ニ彡 ノ` /ト=く ::::::i \ニニニニニニ // ( V^`こ7 _, \``ヾヽ` ノ|`ヽ ヽ l:::::| \ニニニニニ // ∧ { ' ` ノ^ヽ { ノ !:::::| ___ノ^ヽニニニニニニ // /.::::\ゝヽ. _ノヽ``ヽ, -――- 、 /:::::/ /  ̄`ヽニニニニニ // /.::::::::::::::::>'"ノルハヽ`/ -―- 、⌒V::::::/.// j___ノ、 ヽニニニニニ // /ニニ、`ヽ`ヾヘ{ {、ムイ 、_( > \/ (__ ノニニニ \ニニニニ // ,仁ニニニ\ヽヽヽ ∨ /ニニ>彡>--')__ ノ `ヽニ \ニニニ二 // ニニニニニニヽ / {ニニ> ´ `¨¨´ ニ} \>''"´ // ニニニニニニニニ/ ∨ / }八 // ニニニニニニニ./ }ニ{ ノニヽ ノ // ニニニニニニニ/ }ニハ /⌒ヽヽヽ ___彡 // ニニニニニニニ! ノニニヽ、 / ` ー=彡'ニニニニニ // ニニニニニニニ} ⌒`丶、 /⌒ヽ ノ ノ_____ // / ̄ ̄ ̄`ヽ/ヽ、 _彡ヘ{ { > 、 / /  ̄ ̄ ̄ // ) 、 / ヾ、 ヽ ヽ ( `{ / // // ⌒ヽ / 〃 トミ ___ >--‐=、 ヽ _ノ // { / // / \__ノ // ----------------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------------------- let s = read string let delimi = [| '+'; '*' |] let nums = s.Split(delimi) |> Seq.toArray |> Array.map (fun x -> Convert.ToInt64(x)) let ops = Queue<char>() for c in s do if c = '+' || c = '*' then ops.Enqueue(c) let mutable ans = nums.[0] for i in 1 .. Array.length nums - 1 do let o = ops.Dequeue() if o = '+' then ans <- ans * nums.[i] else ans <- ans + nums.[i] puts ans // ----------------------------------------------------------------------------------------------------- writer.Dispose()