結果

問題 No.293 4>7の世界
ユーザー atkrymatkrym
提出日時 2016-10-19 17:14:18
言語 Java
(openjdk 23)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 1,056 bytes
コンパイル時間 2,667 ms
コンパイル使用メモリ 77,592 KB
実行使用メモリ 46,276 KB
最終ジャッジ日時 2024-12-30 12:16:37
合計ジャッジ時間 7,044 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        String a = sc.next();
        String b = sc.next();
        int la = a.length();
        int lb = b.length();
        if (la > lb) {
            System.out.println(a);
            return;
        } else if (lb > la) {
            System.out.println(b);
            return;
        }
        
        for (int i = 0;i < la;i++) {
            int ai = Integer.parseInt(a.substring(i,i+1));
            int bi = Integer.parseInt(b.substring(i,i+1));
            if (ai == bi) continue;
            if (ai == 4 && bi == 7) {
                System.out.println(a);
            } else if (ai == 7 && bi == 4) {
                System.out.println(b);
            } else {
                if (ai > bi) {
                    System.out.println(a);
                } else if (bi > ai) {
                    System.out.println(b);
                }
            }
            return;
        }
    }
}
0