結果

問題 No.293 4>7の世界
ユーザー くわいくわい
提出日時 2015-10-24 22:29:25
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 993 ms / 2,000 ms
コード長 700 bytes
コンパイル時間 14,448 ms
コンパイル使用メモリ 255,412 KB
実行使用メモリ 63,984 KB
最終ジャッジ日時 2023-09-02 07:38:10
合計ジャッジ時間 40,073 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 978 ms
63,248 KB
testcase_01 AC 984 ms
62,696 KB
testcase_02 AC 970 ms
62,840 KB
testcase_03 AC 973 ms
62,800 KB
testcase_04 AC 966 ms
63,248 KB
testcase_05 AC 967 ms
62,692 KB
testcase_06 AC 970 ms
62,720 KB
testcase_07 AC 985 ms
63,088 KB
testcase_08 AC 963 ms
63,252 KB
testcase_09 AC 971 ms
62,872 KB
testcase_10 AC 961 ms
62,644 KB
testcase_11 AC 976 ms
63,284 KB
testcase_12 AC 972 ms
62,968 KB
testcase_13 AC 960 ms
63,060 KB
testcase_14 AC 980 ms
62,768 KB
testcase_15 AC 993 ms
63,228 KB
testcase_16 AC 981 ms
62,652 KB
testcase_17 AC 990 ms
62,892 KB
testcase_18 AC 984 ms
63,304 KB
testcase_19 AC 991 ms
63,296 KB
testcase_20 AC 975 ms
62,764 KB
testcase_21 AC 978 ms
62,740 KB
testcase_22 AC 988 ms
62,884 KB
testcase_23 AC 987 ms
63,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner

object Problem293 {

  def keta(a: Int): Int = a.toString.length

  def max(a: Int, b: Int): Int = {
    if (keta(a) != keta(b)) {
      return a max b
    }

    val sa = a.toString
    val sb = b.toString

    (0 until sa.length) foreach { i =>
      val ca = sa(i) - '0'
      val cb = sb(i) - '0'

      (ca, cb) match {
        case (4, 7) => return a
        case (7, 4) => return b
        case _ if ca != cb => return a max b
        case _ => // eq
      }
    }

    // 同じ
    a
  }

  def main(args: Array[String]) = {
    val sc = new Scanner(System.in)
    val a = sc.nextInt()
    val b = sc.nextInt()

    val result = max(a, b)
    println(result)
  }
}
0