結果

問題 No.293 4>7の世界
ユーザー 5h0t4r0
提出日時 2015-11-02 16:47:57
言語 Scala(Beta)
(3.6.2)
結果
AC  
実行時間 945 ms / 2,000 ms
コード長 657 bytes
コンパイル時間 9,965 ms
コンパイル使用メモリ 261,692 KB
実行使用メモリ 63,512 KB
最終ジャッジ日時 2024-06-29 04:42:53
合計ジャッジ時間 34,030 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

object Yuki293 extends App{
  def compare(a :String, b:String) :String = {
    if(a.length > b.length) return a
    else if (a.length < b.length) return b

    def compareImpl(x :String, y:String, i:Int) :String = {
      if(i >= x.length) return x
      
      val xi = x.charAt(i).asDigit
      val yi = y.charAt(i).asDigit

      if(xi == 4 && yi == 7) x
      else if(xi == 7 && yi == 4) y
      else if(xi == yi) compareImpl(x, y, i + 1)
      else if(xi >= yi) x
      else y 
    }

    compareImpl(a, b, 0)
  }

  val input = new java.util.Scanner(System.in)
  val a = input.next
  val b = input.next
  val result = compare(a, b)
  println(result)
}
0