結果

問題 No.39 桁の数字を入れ替え
ユーザー mbanmban
提出日時 2016-12-22 14:50:34
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 27 ms / 5,000 ms
コード長 760 bytes
コンパイル時間 2,197 ms
コンパイル使用メモリ 112,052 KB
実行使用メモリ 26,892 KB
最終ジャッジ日時 2024-04-10 05:40:21
合計ジャッジ時間 2,687 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
26,800 KB
testcase_01 AC 26 ms
26,624 KB
testcase_02 AC 26 ms
24,468 KB
testcase_03 AC 25 ms
24,716 KB
testcase_04 AC 25 ms
24,724 KB
testcase_05 AC 25 ms
24,852 KB
testcase_06 AC 26 ms
24,588 KB
testcase_07 AC 26 ms
26,632 KB
testcase_08 AC 26 ms
24,748 KB
testcase_09 AC 26 ms
26,892 KB
testcase_10 AC 26 ms
26,668 KB
testcase_11 AC 26 ms
22,328 KB
testcase_12 AC 26 ms
24,628 KB
testcase_13 AC 26 ms
22,580 KB
testcase_14 AC 25 ms
24,712 KB
testcase_15 AC 26 ms
24,748 KB
testcase_16 AC 27 ms
26,680 KB
testcase_17 AC 26 ms
26,552 KB
testcase_18 AC 25 ms
22,580 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;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

class Magatro
{
    static void Main()
    {

        string N = Console.ReadLine();
        long max = long.Parse(N);
        for (int i = 1; i < N.Length; i++)
        {
            for (int j = 0; j < i; j++)
            {
                char[] c = N.ToArray();
                swap(ref c[i], ref c[j]);
                long q = long.Parse(new string(c));
                max = Math.Max(max, q);
            }
        }
        Console.WriteLine(max);
    }
    static void swap(ref char a, ref char b)
    {
        char t = a;
        a = b;
        b = t;
    }
}
0