結果

問題 No.293 4>7の世界
ユーザー shinwisteriashinwisteria
提出日時 2017-03-31 17:15:33
言語 Java
(openjdk 23)
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 810 bytes
コンパイル時間 4,176 ms
コンパイル使用メモリ 76,996 KB
実行使用メモリ 41,328 KB
最終ジャッジ日時 2024-12-30 12:26:18
合計ジャッジ時間 8,936 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Fourseven {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int A = s.nextInt(),B = s.nextInt();
		s.close();
		String a = Integer.toString(A) , b = Integer.toString(B);
		int ka = a.length(),kb = b.length();
		if(ka > kb){
			System.out.println(A);
		}else if(ka < kb){
			System.out.println(B);
		}else{
			boolean tof = false;
			for(int i = 1;i <= ka;i++){
				int ac = Integer.parseInt(a.substring(i-1,i));
				int bc = Integer.parseInt(b.substring(i-1,i));
				//System.out.println(ac + "  " + bc);
				if((ac == 4&&bc == 7) || (ac > bc && (ac != 7||bc != 4))){
					tof = true;
					break;
				}else if(ac != bc){
					break;
				}
			}
			if(tof){
				System.out.println(A);
			}else{
				System.out.println(B);
			}
		}

	}

}
0