結果

問題 No.293 4>7の世界
ユーザー ぴろずぴろず
提出日時 2015-10-23 22:29:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 649 bytes
コンパイル時間 5,374 ms
コンパイル使用メモリ 71,380 KB
実行使用メモリ 56,264 KB
最終ジャッジ日時 2023-08-28 21:43:16
合計ジャッジ時間 6,079 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,800 KB
testcase_01 AC 119 ms
55,588 KB
testcase_02 AC 118 ms
55,696 KB
testcase_03 AC 120 ms
56,264 KB
testcase_04 AC 119 ms
55,480 KB
testcase_05 AC 117 ms
55,760 KB
testcase_06 AC 118 ms
55,540 KB
testcase_07 AC 120 ms
55,712 KB
testcase_08 AC 118 ms
55,460 KB
testcase_09 AC 118 ms
55,512 KB
testcase_10 AC 118 ms
55,420 KB
testcase_11 AC 118 ms
55,588 KB
testcase_12 AC 116 ms
55,828 KB
testcase_13 AC 118 ms
55,680 KB
testcase_14 AC 118 ms
55,596 KB
testcase_15 AC 118 ms
55,800 KB
testcase_16 AC 119 ms
55,600 KB
testcase_17 AC 120 ms
55,956 KB
testcase_18 AC 119 ms
55,688 KB
testcase_19 AC 119 ms
55,588 KB
testcase_20 AC 120 ms
55,616 KB
testcase_21 AC 121 ms
55,600 KB
testcase_22 AC 120 ms
55,420 KB
testcase_23 AC 121 ms
55,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no293;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		System.out.println(less(a,b) ? a : b);
	}

	public static boolean less(String aa,String bb) {
		char[] a = aa.toCharArray();
		char[] b = bb.toCharArray();
		if (a.length != b.length) {
			return a.length > b.length;
		}
		int n = a.length;
		for(int i=0;i<n;i++) {
			if (a[i] != b[i]) {
				if (a[i] == '4' && b[i] == '7' || a[i] == '7' && b[i] == '4') {
					return a[i] < b[i];
				}else{
					return a[i] > b[i];
				}
			}
		}
		return true;
	}

}
0