結果

問題 No.293 4>7の世界
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-14 20:08:18
言語 Java21
(openjdk 21)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 1,136 bytes
コンパイル時間 5,560 ms
コンパイル使用メモリ 74,052 KB
実行使用メモリ 56,524 KB
最終ジャッジ日時 2023-08-28 22:11:46
合計ジャッジ時間 8,075 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,752 KB
testcase_01 AC 118 ms
56,524 KB
testcase_02 AC 119 ms
55,688 KB
testcase_03 AC 119 ms
55,748 KB
testcase_04 AC 118 ms
55,716 KB
testcase_05 AC 119 ms
55,928 KB
testcase_06 AC 118 ms
54,184 KB
testcase_07 AC 120 ms
55,752 KB
testcase_08 AC 120 ms
55,788 KB
testcase_09 AC 120 ms
56,016 KB
testcase_10 AC 118 ms
55,432 KB
testcase_11 AC 121 ms
56,020 KB
testcase_12 AC 119 ms
56,048 KB
testcase_13 AC 119 ms
55,888 KB
testcase_14 AC 118 ms
56,312 KB
testcase_15 AC 116 ms
56,164 KB
testcase_16 AC 117 ms
55,672 KB
testcase_17 AC 115 ms
55,732 KB
testcase_18 AC 117 ms
55,576 KB
testcase_19 AC 118 ms
55,552 KB
testcase_20 AC 117 ms
56,188 KB
testcase_21 AC 116 ms
55,908 KB
testcase_22 AC 118 ms
56,172 KB
testcase_23 AC 118 ms
56,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise80{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    String one = sc.next();
    String two = sc.next();

    if(one.length() == two.length()){
      String[] arrayOne = one.split("");
      String[] arrayTwo = two.split("");

      compare(one, arrayOne, two, arrayTwo);
    }else{
      if (one.length() > two.length()){
        System.out.println(one);
      }else{
        System.out.println(two);
      }
    }
  }

  private static void compare(String one, String[] arrayOne, String two, String[] arrayTwo){
    for(int i = 0; i < arrayOne.length; i++){
      if(arrayOne[i].equals("4") && arrayTwo[i].equals("7")){
        arrayOne[i] = "7";
        arrayTwo[i] = "4";
      }else if(arrayOne[i].equals("7") && arrayTwo[i].equals("4")){
        arrayOne[i] = "4";
        arrayTwo[i] = "7";
      }
    }

    String newOne = String.join("", arrayOne);
    String newTwo = String.join("", arrayTwo);

    if(Integer.parseInt(newOne) > Integer.parseInt(newTwo)){
      System.out.println(one);
    }else{
      System.out.println(two);
    }
  }
}
0