結果

問題 No.39 桁の数字を入れ替え
ユーザー AreTrashAreTrash
提出日時 2016-04-16 15:53:33
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 765 bytes
コンパイル時間 849 ms
コンパイル使用メモリ 109,808 KB
実行使用メモリ 26,660 KB
最終ジャッジ日時 2024-04-15 02:11:23
合計ジャッジ時間 1,965 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
24,732 KB
testcase_01 AC 24 ms
26,660 KB
testcase_02 AC 25 ms
26,416 KB
testcase_03 AC 24 ms
24,616 KB
testcase_04 AC 25 ms
24,608 KB
testcase_05 AC 24 ms
24,728 KB
testcase_06 AC 24 ms
24,476 KB
testcase_07 AC 23 ms
24,632 KB
testcase_08 WA -
testcase_09 AC 24 ms
24,488 KB
testcase_10 AC 24 ms
24,616 KB
testcase_11 AC 24 ms
24,608 KB
testcase_12 AC 25 ms
24,736 KB
testcase_13 AC 23 ms
24,616 KB
testcase_14 AC 24 ms
24,608 KB
testcase_15 AC 24 ms
24,620 KB
testcase_16 AC 24 ms
24,476 KB
testcase_17 AC 24 ms
24,732 KB
testcase_18 AC 23 ms
24,736 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 + 1; 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