結果

問題 No.293 4>7の世界
ユーザー shi-mo
提出日時 2016-10-26 12:50:11
言語 Ruby
(3.4.1)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 356 bytes
コンパイル時間 549 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-12-30 12:17:19
合計ジャッジ時間 3,936 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

a, b = gets.split.map(&:to_i)

if a == b
  puts a
  exit 0
end

sa, sb = [a, b].map{|n| sprintf "%010d", n }

10.times do |i|
  ca = sa[i].to_i
  cb = sb[i].to_i

  next if ca == cb

  if 4 == ca && 7 == cb
    puts a
    exit 0
  end
  if 7 == ca && 4 == cb
    puts b
    exit 0
  end

  puts (ca < cb) ? b : a
  exit 0
end

warn 'must not happen'
exit 1
0