結果
問題 | No.1298 OR XOR |
ユーザー |
![]() |
提出日時 | 2024-08-06 01:23:40 |
言語 | Elixir (1.18.1) |
結果 |
AC
|
実行時間 | 607 ms / 2,000 ms |
コード長 | 827 bytes |
コンパイル時間 | 1,824 ms |
コンパイル使用メモリ | 61,428 KB |
実行使用メモリ | 54,412 KB |
最終ジャッジ日時 | 2024-08-06 01:23:55 |
合計ジャッジ時間 | 11,558 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 13 |
ソースコード
defmoduleMain dodef input, do: IO.read(:line) |> String.trimdef ii, do: input() |> String.to_integerdef li, do: input() |> String.split |> Enum.map(&String.to_integer/1)def yn(b), do: IO.puts(if b, do: "Yes", else: "No")# import Bitwise, only: [bxor: 2, &&&: 2, >>>: 2]#use Bitwiseimport Bitwise, only: :functionsdef bin(n), do: :io_lib.format("~.2b", [n])# 最下位ビット@spec lsb(integer()) :: integer()def lsb(x), do: x &&& -xdef main don = ii()if bit_count(n) == 1 doIO.puts Enum.join([-1, -1, -1], " ")elseb = lsb(n)x = bxor(n, b)IO.puts Enum.join([n, b, x], " ")endenddef bit_count(0), do: 0def bit_count(x) doif (x &&& 1) == 1 do1 + bit_count(x >>> 1)elsebit_count(x >>> 1)endendend