結果

問題 No.293 4>7の世界
ユーザー nanaenanae
提出日時 2017-01-08 16:30:29
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 685 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-12-30 12:20:39
合計ジャッジ時間 1,870 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

# yukicoder No.293 4>7の世界

A, B = input().split()

if len(A) != len(B): # 桁が違うなら単に大きい方
    print(max(int(A), int(B)))
else: # 桁が同じのとき
    for (i, j) in zip(A, B): # 最高位から順に比較していく
        # 4,7の組合せになったときだけ順序が入れ替わる
        if int(i) == 4 and int(j) == 7 or int(i) == 7 and int(j) == 4:
            print(min(A, B))
            break
        # 4,7の組合せでなく、異なる数字同士の場合は普通の比較
        elif i != j:
            print(max(A, B))
            break
        # 桁の数字が同じなら一つ下を見る
        else:
            continue
0