結果

問題 No.293 4>7の世界
ユーザー nCk_cvnCk_cv
提出日時 2015-10-27 19:29:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 939 bytes
コンパイル時間 2,190 ms
コンパイル使用メモリ 74,796 KB
実行使用メモリ 56,296 KB
最終ジャッジ日時 2023-08-28 21:53:23
合計ジャッジ時間 6,100 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,692 KB
testcase_01 AC 120 ms
55,396 KB
testcase_02 AC 118 ms
55,816 KB
testcase_03 AC 118 ms
55,644 KB
testcase_04 AC 117 ms
55,588 KB
testcase_05 AC 118 ms
55,760 KB
testcase_06 AC 118 ms
55,744 KB
testcase_07 AC 118 ms
56,132 KB
testcase_08 AC 118 ms
56,296 KB
testcase_09 AC 117 ms
55,756 KB
testcase_10 AC 119 ms
55,396 KB
testcase_11 AC 118 ms
55,912 KB
testcase_12 AC 117 ms
55,792 KB
testcase_13 AC 120 ms
55,620 KB
testcase_14 AC 116 ms
55,772 KB
testcase_15 AC 115 ms
55,692 KB
testcase_16 AC 118 ms
53,624 KB
testcase_17 AC 118 ms
55,532 KB
testcase_18 AC 117 ms
55,960 KB
testcase_19 AC 118 ms
55,692 KB
testcase_20 AC 119 ms
55,336 KB
testcase_21 AC 119 ms
55,764 KB
testcase_22 AC 119 ms
55,632 KB
testcase_23 AC 118 ms
55,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.math.*;
import java.awt.geom.*;
import java.io.*;
    
    
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		int ans = compare(a,b);
		
		if(ans > 0) {
			System.out.println(a);
		}
		else if (ans < 0){
			System.out.println(b);
		}
	}
	
	static int compare(String a, String b) {
		if(a.equals(b)) return 0;
		if(a.length() > b.length()) return 1;
		else if(a.length() < b.length()) return -1;
		else {
			for(int i = 0; i < a.length(); i++) {
				if(a.charAt(i) == b.charAt(i)) continue;
				if(a.charAt(i) == '4' && b.charAt(i) == '7') {
					return 1;
				}
				if(a.charAt(i) == '7' && b.charAt(i) == '4') {
					return -1;
				}
				return Integer.parseInt(String.valueOf(String.valueOf(a.charAt(i)))) - Integer.parseInt(String.valueOf(String.valueOf(b.charAt(i))));
			}
		}
		return 0;
		
	}
	
	
}
0