結果

問題 No.683 Two Operations No.3
ユーザー むらためむらため
提出日時 2019-01-26 12:45:54
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 585 bytes
コンパイル時間 2,163 ms
コンパイル使用メモリ 66,292 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-14 02:55:34
合計ジャッジ時間 2,780 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  while true:
    let k = getchar_unlocked()
    if k < '0': break
    result = 10 * result + k.ord - '0'.ord

proc solve(a,b:int):bool =
  var a = min(a,b)
  var b = max(a,b)
  if a == 0 : return b <= 1
  if a mod 2 == 1 :
    if b mod 2 == 1 : return false
    return solve(a-1,b div 2)
  if b mod 2 == 1 : return solve(a div 2,b - 1)
  if solve(a div 2 , b - 1) : return true
  return solve(a - 1 , b div 2)

let a = scan()
let b = scan()
if solve(a,b) : echo "YES"
else: echo "NO"
0