結果

問題 No.293 4>7の世界
ユーザー 5h0t4r05h0t4r0
提出日時 2015-11-02 16:47:57
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 944 ms / 2,000 ms
コード長 657 bytes
コンパイル時間 8,243 ms
コンパイル使用メモリ 245,940 KB
実行使用メモリ 63,364 KB
最終ジャッジ日時 2023-09-11 14:30:30
合計ジャッジ時間 32,487 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 918 ms
62,872 KB
testcase_01 AC 921 ms
62,936 KB
testcase_02 AC 902 ms
63,144 KB
testcase_03 AC 911 ms
62,904 KB
testcase_04 AC 913 ms
62,936 KB
testcase_05 AC 931 ms
62,988 KB
testcase_06 AC 936 ms
63,076 KB
testcase_07 AC 944 ms
63,088 KB
testcase_08 AC 929 ms
62,884 KB
testcase_09 AC 914 ms
62,880 KB
testcase_10 AC 915 ms
62,980 KB
testcase_11 AC 906 ms
62,888 KB
testcase_12 AC 915 ms
62,972 KB
testcase_13 AC 916 ms
62,900 KB
testcase_14 AC 925 ms
63,300 KB
testcase_15 AC 911 ms
62,812 KB
testcase_16 AC 923 ms
63,072 KB
testcase_17 AC 919 ms
62,748 KB
testcase_18 AC 921 ms
63,348 KB
testcase_19 AC 923 ms
63,012 KB
testcase_20 AC 932 ms
62,928 KB
testcase_21 AC 926 ms
63,104 KB
testcase_22 AC 927 ms
63,016 KB
testcase_23 AC 936 ms
63,364 KB
権限があれば一括ダウンロードができます

ソースコード

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