結果

問題 No.293 4>7の世界
ユーザー NoNo
提出日時 2015-11-03 00:07:04
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 1,606 bytes
コンパイル時間 2,233 ms
コンパイル使用メモリ 103,344 KB
実行使用メモリ 22,904 KB
最終ジャッジ日時 2023-10-11 12:57:26
合計ジャッジ時間 5,208 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 56 ms
20,848 KB
testcase_04 AC 56 ms
22,860 KB
testcase_05 AC 56 ms
20,872 KB
testcase_06 RE -
testcase_07 AC 55 ms
20,772 KB
testcase_08 AC 55 ms
18,676 KB
testcase_09 AC 56 ms
20,904 KB
testcase_10 AC 55 ms
22,740 KB
testcase_11 AC 55 ms
20,704 KB
testcase_12 AC 54 ms
22,880 KB
testcase_13 AC 56 ms
20,868 KB
testcase_14 AC 55 ms
20,608 KB
testcase_15 AC 56 ms
22,736 KB
testcase_16 RE -
testcase_17 AC 55 ms
22,708 KB
testcase_18 AC 56 ms
20,820 KB
testcase_19 AC 55 ms
18,840 KB
testcase_20 RE -
testcase_21 AC 55 ms
20,896 KB
testcase_22 AC 56 ms
22,864 KB
testcase_23 AC 55 ms
22,904 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Yuki
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a = Console.ReadLine().Split();
            int b = a[0].Length > a[1].Length ? a[0].Length - 1 : a[1].Length - 1;
            string w0 = a[0];
            string w1 = a[1];


            for (int i = b; i > -1; i--)
            {
                if ((a[0][i] == '4') && (a[1][i] == '7'))
                {
                    a[0] = a[0].Insert(i, "7");
                    a[0] = a[0].Remove(i + 1, 1);
                    a[1] = a[1].Insert(i, "4");
                    a[1] = a[1].Remove(i + 1, 1);

                    continue;
                }
                if ((a[0][i] == '7') && (a[1][i] == '4'))
                {
                    a[0] = a[0].Insert(i, "4");
                    a[0] = a[0].Remove(i + 1, 1);
                    a[1] = a[1].Insert(i, "7");
                    a[1] = a[1].Remove(i + 1, 1);

                }
            }

            string ans = int.Parse(a[0]) > int.Parse(a[1]) ? w0 : w1;
            Console.Write(ans);
            Console.ReadLine();
        }

        static int[] ConvertStringArrayToIntArray(string[] array)
        {
            return Array.ConvertAll(array, str => int.Parse(str));
        }

        static List<int> ConvertStringArrayToIntList(string[] str)
        {
            var list = new List<int>();
            foreach (var c in str) list.Add(int.Parse(c));
            return list;
        }
    }
}
0