結果

問題 No.39 桁の数字を入れ替え
ユーザー AreTrashAreTrash
提出日時 2016-04-16 15:54:45
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 27 ms / 5,000 ms
コード長 761 bytes
コンパイル時間 843 ms
コンパイル使用メモリ 114,064 KB
実行使用メモリ 26,920 KB
最終ジャッジ日時 2024-04-10 05:21:48
合計ジャッジ時間 2,124 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
26,780 KB
testcase_01 AC 25 ms
24,732 KB
testcase_02 AC 26 ms
26,788 KB
testcase_03 AC 26 ms
24,620 KB
testcase_04 AC 26 ms
24,476 KB
testcase_05 AC 26 ms
26,788 KB
testcase_06 AC 26 ms
24,484 KB
testcase_07 AC 26 ms
24,732 KB
testcase_08 AC 26 ms
26,788 KB
testcase_09 AC 26 ms
24,624 KB
testcase_10 AC 27 ms
26,664 KB
testcase_11 AC 26 ms
26,920 KB
testcase_12 AC 25 ms
22,712 KB
testcase_13 AC 26 ms
24,624 KB
testcase_14 AC 26 ms
26,424 KB
testcase_15 AC 26 ms
24,740 KB
testcase_16 AC 27 ms
26,648 KB
testcase_17 AC 26 ms
26,656 KB
testcase_18 AC 26 ms
22,836 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.Linq;

namespace No39_1{
    public class Program{
        public static void Main(string[] args){
            var n = Console.ReadLine().ToCharArray();
            var length = n.Length;
            var max = 0;

            for(var i = 0; i < length; i++){
                for(var j = i; j < length; j++){
                    var tmp = new char[length];
                    n.CopyTo(tmp, 0);
                    var t = tmp[i];
                    tmp[i] = tmp[j];
                    tmp[j] = t;

                    string str = tmp.Aggregate(string.Empty, (current, c) => current + c);
                    max = Math.Max(max, int.Parse(str));
                }
            }

            Console.WriteLine(max);
        }
    }
}
0