結果

問題 No.83 最大マッチング
ユーザー naotest2naotest2
提出日時 2017-05-24 13:49:00
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 352 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 11,908 KB
実行使用メモリ 16,092 KB
最終ジャッジ日時 2023-10-19 19:59:06
合計ジャッジ時間 2,663 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
16,040 KB
testcase_01 AC 85 ms
16,040 KB
testcase_02 AC 86 ms
16,040 KB
testcase_03 AC 85 ms
16,040 KB
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
  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