結果

問題 No.642 Two Operations No.1
ユーザー taktak
提出日時 2018-03-20 11:05:53
言語 F#
(F# 4.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 324 bytes
コンパイル時間 5,187 ms
コンパイル使用メモリ 163,128 KB
実行使用メモリ 26,820 KB
最終ジャッジ日時 2023-09-05 15:17:53
合計ジャッジ時間 7,496 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
22,588 KB
testcase_01 AC 80 ms
22,636 KB
testcase_02 AC 82 ms
26,820 KB
testcase_03 AC 81 ms
24,772 KB
testcase_04 AC 79 ms
22,728 KB
testcase_05 AC 81 ms
24,644 KB
testcase_06 AC 80 ms
22,656 KB
testcase_07 AC 80 ms
24,640 KB
testcase_08 AC 80 ms
22,740 KB
testcase_09 AC 80 ms
22,612 KB
testcase_10 AC 80 ms
22,740 KB
testcase_11 AC 86 ms
24,640 KB
testcase_12 AC 81 ms
22,764 KB
testcase_13 AC 80 ms
22,620 KB
testcase_14 AC 81 ms
22,916 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

open System

let isOdd n = (n &&& 1) = 1
let op1 n = n+1
let op2 n = n/2

let N = Console.ReadLine() |> int

let rec f n cnt =
    match n with 
    | 1 -> cnt
    | x -> 
        if isOdd x then 
            f (op1 x) (cnt+1)
        else
            f (op2 x) (cnt+1)                                

f N 0
|> printfn "%i"
0