結果

問題 No.293 4>7の世界
ユーザー shinwisteriashinwisteria
提出日時 2017-03-31 17:15:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 810 bytes
コンパイル時間 3,427 ms
コンパイル使用メモリ 77,560 KB
実行使用メモリ 56,288 KB
最終ジャッジ日時 2023-08-28 22:19:43
合計ジャッジ時間 7,703 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,972 KB
testcase_01 AC 123 ms
55,888 KB
testcase_02 AC 122 ms
56,136 KB
testcase_03 AC 123 ms
55,756 KB
testcase_04 AC 123 ms
55,904 KB
testcase_05 AC 123 ms
56,084 KB
testcase_06 AC 123 ms
55,760 KB
testcase_07 AC 125 ms
56,172 KB
testcase_08 AC 124 ms
56,196 KB
testcase_09 AC 120 ms
55,808 KB
testcase_10 AC 123 ms
55,948 KB
testcase_11 AC 124 ms
55,900 KB
testcase_12 AC 124 ms
55,744 KB
testcase_13 AC 122 ms
56,080 KB
testcase_14 AC 122 ms
55,804 KB
testcase_15 AC 124 ms
55,972 KB
testcase_16 AC 123 ms
56,288 KB
testcase_17 AC 122 ms
55,872 KB
testcase_18 AC 122 ms
55,908 KB
testcase_19 AC 122 ms
55,684 KB
testcase_20 AC 123 ms
55,920 KB
testcase_21 AC 125 ms
55,552 KB
testcase_22 AC 123 ms
56,236 KB
testcase_23 AC 122 ms
55,784 KB
権限があれば一括ダウンロードができます

ソースコード

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