結果

問題 No.293 4>7の世界
ユーザー NoNo
提出日時 2015-11-03 01:07:12
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 1,823 bytes
コンパイル時間 2,347 ms
コンパイル使用メモリ 106,944 KB
実行使用メモリ 22,860 KB
最終ジャッジ日時 2023-08-28 21:54:03
合計ジャッジ時間 4,737 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
22,860 KB
testcase_01 AC 57 ms
18,796 KB
testcase_02 AC 57 ms
20,776 KB
testcase_03 AC 56 ms
18,728 KB
testcase_04 AC 56 ms
18,812 KB
testcase_05 AC 57 ms
20,724 KB
testcase_06 AC 57 ms
20,844 KB
testcase_07 AC 57 ms
20,688 KB
testcase_08 AC 56 ms
20,804 KB
testcase_09 AC 58 ms
22,768 KB
testcase_10 AC 57 ms
22,688 KB
testcase_11 AC 56 ms
20,756 KB
testcase_12 AC 56 ms
20,912 KB
testcase_13 AC 57 ms
22,828 KB
testcase_14 AC 57 ms
20,828 KB
testcase_15 AC 57 ms
18,688 KB
testcase_16 AC 56 ms
20,840 KB
testcase_17 AC 57 ms
22,744 KB
testcase_18 AC 57 ms
20,856 KB
testcase_19 AC 57 ms
22,784 KB
testcase_20 AC 57 ms
20,732 KB
testcase_21 AC 56 ms
18,680 KB
testcase_22 AC 56 ms
22,824 KB
testcase_23 AC 57 ms
20,768 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[1].Length : a[0].Length;
            string w0 = a[0];
            string w1 = a[1];

            for (int i = 0; i < b; i++)
            {
                string aa = a[0].Substring(a[0].Length - 1 - i,1);
                string bb = a[1].Substring(a[1].Length - 1 - i,1);

                if ((aa == "4") && (bb == "7"))
                {
                    a[0] = a[0].Remove(a[0].Length -1 -i,1);
                    a[0] = a[0].Insert(a[0].Length  - i, "7");
                    a[1] = a[1].Remove(a[1].Length - 1 - i, 1);
                    a[1] = a[1].Insert(a[1].Length  - i, "4");
                    continue;
                }

                if ((aa == "7") && (bb == "4"))
                {
                    a[0] = a[0].Remove(a[0].Length - 1 - i, 1);
                    a[0] = a[0].Insert(a[0].Length  - i, "4");
                    a[1] = a[1].Remove(a[1].Length - 1 - i, 1);
                    a[1] = a[1].Insert(a[1].Length  - i, "7");
                }
            }

            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