結果

問題 No.293 4>7の世界
ユーザー tsuchinagatsuchinaga
提出日時 2019-03-29 12:11:09
言語 Go
(1.21.3)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 675 bytes
コンパイル時間 16,758 ms
コンパイル使用メモリ 203,904 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-08-06 22:06:26
合計ジャッジ時間 18,401 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,356 KB
testcase_01 AC 2 ms
4,356 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 1 ms
4,356 KB
testcase_04 AC 1 ms
4,356 KB
testcase_05 AC 1 ms
4,356 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 1 ms
4,356 KB
testcase_08 AC 1 ms
4,356 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 2 ms
4,356 KB
testcase_11 AC 1 ms
4,356 KB
testcase_12 AC 1 ms
4,356 KB
testcase_13 AC 2 ms
4,356 KB
testcase_14 AC 1 ms
4,352 KB
testcase_15 AC 1 ms
4,356 KB
testcase_16 AC 1 ms
4,356 KB
testcase_17 AC 2 ms
4,352 KB
testcase_18 AC 1 ms
4,356 KB
testcase_19 AC 2 ms
4,356 KB
testcase_20 AC 1 ms
4,356 KB
testcase_21 AC 1 ms
4,356 KB
testcase_22 AC 1 ms
4,352 KB
testcase_23 AC 1 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import "fmt"

func main() {
	var a, b string
	_, _ = fmt.Scan(&a, &b)

	if len(a) > len(b) {
		fmt.Println(a)
	} else if len(a) < len(b) {
		fmt.Println(b)
	} else { // 長さが等しい
		for i := 0; i < len(a); i++ {
			if a[i] == b[i] {
				// 同じ桁の値が同じなら次の桁に移る
				continue
			}

			if (a[i] != '4' && a[i] != '7') || (b[i] != '4' && b[i] != '7') { // 少なくとも片方が4でも7でもない
				if a[i] > b[i] {
					fmt.Println(a)
				} else {
					fmt.Println(b)
				}
			} else { // 両方4か7で一致しない
				if a[i] == '4' {
					fmt.Println(a)
				} else {
					fmt.Println(b)
				}
			}
			break
		}
	}
}
0