結果

問題 No.1450 nahco314's First Problem
ユーザー simansiman
提出日時 2021-07-06 19:26:37
言語 Ruby
(3.3.0)
結果
AC  
実行時間 727 ms / 2,000 ms
コード長 162 bytes
コンパイル時間 399 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 13,696 KB
最終ジャッジ日時 2024-04-26 02:10:04
合計ジャッジ時間 19,289 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
12,160 KB
testcase_01 AC 260 ms
12,544 KB
testcase_02 AC 358 ms
12,672 KB
testcase_03 AC 102 ms
12,160 KB
testcase_04 AC 98 ms
12,160 KB
testcase_05 AC 257 ms
12,544 KB
testcase_06 AC 721 ms
13,312 KB
testcase_07 AC 410 ms
13,440 KB
testcase_08 AC 727 ms
13,440 KB
testcase_09 AC 398 ms
13,440 KB
testcase_10 AC 405 ms
13,568 KB
testcase_11 AC 400 ms
13,440 KB
testcase_12 AC 403 ms
13,440 KB
testcase_13 AC 401 ms
13,696 KB
testcase_14 AC 409 ms
13,696 KB
testcase_15 AC 403 ms
13,440 KB
testcase_16 AC 401 ms
13,568 KB
testcase_17 AC 398 ms
13,440 KB
testcase_18 AC 717 ms
13,312 KB
testcase_19 AC 384 ms
13,568 KB
testcase_20 AC 405 ms
13,696 KB
testcase_21 AC 396 ms
13,568 KB
testcase_22 AC 702 ms
13,440 KB
testcase_23 AC 399 ms
13,440 KB
testcase_24 AC 393 ms
13,568 KB
testcase_25 AC 397 ms
13,440 KB
testcase_26 AC 394 ms
13,696 KB
testcase_27 AC 390 ms
13,440 KB
testcase_28 AC 390 ms
13,440 KB
testcase_29 AC 403 ms
13,440 KB
testcase_30 AC 395 ms
13,440 KB
testcase_31 AC 698 ms
13,312 KB
testcase_32 AC 405 ms
13,568 KB
testcase_33 AC 704 ms
13,440 KB
testcase_34 AC 399 ms
13,440 KB
testcase_35 AC 722 ms
13,568 KB
testcase_36 AC 710 ms
13,312 KB
testcase_37 AC 406 ms
13,696 KB
testcase_38 AC 394 ms
13,696 KB
testcase_39 AC 403 ms
13,440 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:14: warning: ambiguous first argument; put parentheses or a space even after `-' operator
Syntax OK

ソースコード

diff #

X = gets.to_i

(X - 2 ** 18).upto(X + 2 ** 18) do |n|
  next if n <= 0
  m = n.to_s(2).count('1')
  x = n ^ m

  if x == X
    puts n
    exit
  end
end

puts -1
0