結果

問題 No.83 最大マッチング
ユーザー naotest2naotest2
提出日時 2017-05-24 13:48:31
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 361 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 11,912 KB
実行使用メモリ 16,100 KB
最終ジャッジ日時 2023-10-19 19:56:55
合計ジャッジ時間 2,133 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N=gets.chomp.to_i

def match(n)
  # 6 => 9
  # 5 => 5
  # 4 => 4
  # 3 => 7
  # 2 => 1
  # 1 か 7しかない
  seven = n % 2 == 1
  c = -1
  while n > 0
    c += 1
    n = n >> 1
  end
  puts c
  ret = 0
  for num in 0..c-1
    if num == (c-1) and seven
      ret += 10 ** num * 7
    else
      ret += 10 ** num
    end
  end
  return ret
end

puts match(N)
0