結果

問題 No.293 4>7の世界
ユーザー tentententen
提出日時 2023-07-27 14:53:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 2,206 bytes
コンパイル時間 2,611 ms
コンパイル使用メモリ 89,920 KB
実行使用メモリ 50,556 KB
最終ジャッジ日時 2024-04-15 02:30:04
合計ジャッジ時間 5,017 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
50,556 KB
testcase_01 AC 56 ms
50,412 KB
testcase_02 AC 57 ms
50,436 KB
testcase_03 AC 60 ms
50,400 KB
testcase_04 AC 57 ms
50,392 KB
testcase_05 AC 59 ms
50,420 KB
testcase_06 AC 61 ms
50,076 KB
testcase_07 AC 57 ms
50,480 KB
testcase_08 AC 58 ms
50,504 KB
testcase_09 AC 58 ms
50,472 KB
testcase_10 AC 58 ms
50,316 KB
testcase_11 AC 58 ms
50,416 KB
testcase_12 AC 58 ms
50,120 KB
testcase_13 AC 58 ms
50,496 KB
testcase_14 AC 57 ms
50,332 KB
testcase_15 AC 57 ms
50,432 KB
testcase_16 AC 59 ms
50,396 KB
testcase_17 AC 58 ms
50,504 KB
testcase_18 AC 57 ms
50,180 KB
testcase_19 AC 58 ms
50,032 KB
testcase_20 AC 57 ms
50,380 KB
testcase_21 AC 57 ms
50,364 KB
testcase_22 AC 57 ms
50,132 KB
testcase_23 AC 57 ms
50,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        char[] a = sc.next().toCharArray();
        char[] b = sc.next().toCharArray();
        if (check(a, b) < 0) {
            System.out.println(b);
        } else {
            System.out.println(a);
        }
    }
    
    static int check(char[] a, char[] b) {
        if (a.length == b.length) {
            for (int i = 0; i < a.length; i++) {
                if (a[i] != b[i]) {
                    if (a[i] == '4' && b[i] == '7') {
                        return 1;
                    } else if (a[i] == '7' && b[i] == '4') {
                        return -1;
                    } else {
                        return a[i] - b[i];
                    }
                }
            }
            return 0;
        } else {
            return a.length - b.length;
        }
    }
} 
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0