結果

問題 No.939 and or
ユーザー guricerin
提出日時 2020-01-02 10:50:25
言語 F#
(F# 4.0)
結果
AC  
実行時間 350 ms / 2,000 ms
コード長 962 bytes
コンパイル時間 15,289 ms
コンパイル使用メモリ 198,420 KB
実行使用メモリ 34,632 KB
最終ジャッジ日時 2024-11-22 17:50:59
合計ジャッジ時間 24,139 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (356 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
/home/judge/data/code/Main.fs(27,9): warning FS0025: この式のパターン マッチが不完全です たとえば、値 '[|_; _; _|]' はパターンに含まれないケースを示す可能性があります。 [/home/judge/data/code/main.fsproj]
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

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 readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

module Util =
    let strRev s =
        s
        |> Seq.rev
        |> Seq.map string
        |> String.concat ""

    let inline roundup (a: ^t) (b: ^t): ^t =
        let one = LanguagePrimitives.GenericOne
        (a + b - one) / b

[<EntryPoint>]
let main _ =
    let [|a;b|] = reada int64

    if (a &&& b <> a) then
        printfn "0"
    else
        let mutable ca = 0
        let mutable cb = 0
        for i in 0..33 do
            if (a >>> i) &&& 1L = 1L then ca <- ca + 1
            if (b >>> i) &&& 1L = 1L then cb <- cb + 1
        let e = max (cb - ca - 1) 0
        let ans = 1 <<< e
        printfn "%d" ans
    0 // return an integer exit code
0