結果

問題 No.638 Sum of "not power of 2"
ユーザー taktak
提出日時 2018-04-23 16:25:48
言語 F#
(F# 4.0)
結果
AC  
実行時間 94 ms / 1,000 ms
コード長 514 bytes
コンパイル時間 3,262 ms
コンパイル使用メモリ 155,476 KB
実行使用メモリ 25,256 KB
最終ジャッジ日時 2023-09-09 21:36:51
合計ジャッジ時間 5,383 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
25,108 KB
testcase_01 AC 86 ms
23,144 KB
testcase_02 AC 86 ms
22,944 KB
testcase_03 AC 87 ms
25,040 KB
testcase_04 AC 93 ms
23,112 KB
testcase_05 AC 86 ms
23,120 KB
testcase_06 AC 93 ms
25,256 KB
testcase_07 AC 94 ms
23,104 KB
testcase_08 AC 93 ms
23,068 KB
testcase_09 AC 94 ms
23,284 KB
testcase_10 AC 92 ms
23,140 KB
testcase_11 AC 93 ms
23,192 KB
testcase_12 AC 87 ms
25,032 KB
testcase_13 AC 93 ms
25,248 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

let isEnable N =
    let powOf2Set =
        let powOf2Seq = Seq.unfold (fun x -> if x>N then None else Some(x,x*2L)) 1L     
        powOf2Seq |> Set.ofSeq
    let lis = [3L .. (min (N-1L) 130L)]
    lis |> List.tryFind(fun x -> 
        let y = N-x        
        not (powOf2Set.Contains x) && not (powOf2Set.Contains y))    
        
let N = stdin.ReadLine() |> int64
        
N
|> isEnable
|> function
    | None    -> sprintf "-1"
    | Some(x) -> sprintf "%i %i" x (N-x)
|> printfn "%s"                     
0