結果
| 問題 |
No.939 and or
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2024-08-06 21:22:50 |
| 言語 | Elixir (1.18.1) |
| 結果 |
AC
|
| 実行時間 | 534 ms / 2,000 ms |
| コード長 | 862 bytes |
| コンパイル時間 | 1,994 ms |
| コンパイル使用メモリ | 62,552 KB |
| 実行使用メモリ | 55,280 KB |
| 最終ジャッジ日時 | 2024-08-06 21:23:11 |
| 合計ジャッジ時間 | 19,310 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
ソースコード
defmodule Main do
def input, do: IO.read(:line) |> String.trim
def ii, do: input() |> String.to_integer
def li, do: input() |> String.split |> Enum.map(&String.to_integer/1)
def yn(b), do: IO.puts(if b, do: "Yes", else: "No")
def comma(x) do
s = Integer.to_string(x) |> String.graphemes
{a, b} = Enum.split(s, rem(length(s), 3))
[a] ++ (b |> Enum.chunk_every(3))
|> Enum.join(",")
|> String.trim_leading(",")
end
def bin(x), do: :io_lib.format("~.2b", [x])
import Bitwise
def main do
[a, b] = li()
cond do
a == b -> 1
band(a, b) == a ->
cnt = bit_count(bxor(a, b))
div(2 ** cnt, 2)
true -> 0
end
|> IO.puts
end
def bit_count(0), do: 0
def bit_count(x) do
if (x &&& 1) == 1 do
1 + bit_count(x >>> 1)
else
bit_count(x >>> 1)
end
end
end
norioc