結果

問題 No.293 4>7の世界
ユーザー ottfoekstottfoekst
提出日時 2015-11-08 02:18:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 870 bytes
コンパイル時間 4,909 ms
コンパイル使用メモリ 71,684 KB
実行使用メモリ 56,392 KB
最終ジャッジ日時 2023-08-28 21:56:29
合計ジャッジ時間 8,446 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
56,084 KB
testcase_01 AC 124 ms
55,880 KB
testcase_02 AC 124 ms
56,068 KB
testcase_03 AC 123 ms
55,796 KB
testcase_04 AC 124 ms
55,792 KB
testcase_05 AC 123 ms
56,316 KB
testcase_06 AC 126 ms
55,960 KB
testcase_07 AC 125 ms
55,680 KB
testcase_08 AC 124 ms
55,724 KB
testcase_09 AC 127 ms
55,792 KB
testcase_10 AC 123 ms
55,768 KB
testcase_11 AC 122 ms
55,796 KB
testcase_12 AC 122 ms
56,040 KB
testcase_13 AC 124 ms
55,904 KB
testcase_14 AC 126 ms
55,700 KB
testcase_15 AC 124 ms
55,732 KB
testcase_16 AC 125 ms
55,548 KB
testcase_17 AC 123 ms
55,860 KB
testcase_18 AC 122 ms
55,956 KB
testcase_19 AC 124 ms
55,736 KB
testcase_20 AC 123 ms
56,244 KB
testcase_21 AC 123 ms
55,812 KB
testcase_22 AC 123 ms
55,872 KB
testcase_23 AC 123 ms
56,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No293 {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String[] numList = scanner.nextLine().split(" ");
		System.out.println(compare(numList[0], numList[1]) > 0 ? numList[0] : numList[1]);
		scanner.close();
	}
		
	private static int compare(String str1, String str2) {
		if(str1.length() > str2.length()) {
			return 1;
		}
		else if(str1.length() < str2.length()) {
			return -1;
		}
		else {
			for(int index = 0; index < str1.length(); index++) {
				char str1Char = str1.charAt(index);
				char str2Char = str2.charAt(index);
				if(str1Char == '4' && str2Char == '7' ) {
					return 1;
				}
				else if(str1Char == '7' && str2Char == '4') {
					return -1;
				}
				else {
					if(str1Char != str2Char) {
						return str1Char - str2Char;
					}
				}
			}
			return 0;
		}
	}
}
0