結果

問題 No.293 4>7の世界
ユーザー rf141
提出日時 2015-12-19 19:09:09
言語 Java
(openjdk 23)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 843 bytes
コンパイル時間 2,150 ms
コンパイル使用メモリ 77,784 KB
実行使用メモリ 54,164 KB
最終ジャッジ日時 2024-09-16 16:11:05
合計ジャッジ時間 6,086 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Main{
	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();

		if(a < b){
			System.out.println(getResult(b,a));
		}else if(b < a){
			System.out.println(getResult(a,b));
		}else{
			System.out.println(a);
		}
	}

	public static int getResult(int l,int s){
		String l_s = String.valueOf(l);
		String s_s = String.valueOf(s);
		if(l_s.length() != s_s.length())return l;
		if(l_s.indexOf("7") == -1 && s_s.indexOf("7") == -1)return l;
		int result = l;
		for(int i = 0; i < l_s.length(); i++){
			if(l_s.charAt(i) != s_s.charAt(i)){
				if(l_s.charAt(i) == '4' && s_s.charAt(i) == '7'){
					break;
				}else if(s_s.charAt(i) == '4' && l_s.charAt(i) == '7'){
					result = s;
					break;
				}
			}
		}

		return result;
	}
}
0