結果
問題 |
No.39 桁の数字を入れ替え
|
ユーザー |
![]() |
提出日時 | 2018-10-07 20:26:33 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 28 ms / 5,000 ms |
コード長 | 807 bytes |
コンパイル時間 | 866 ms |
コンパイル使用メモリ | 111,080 KB |
実行使用メモリ | 26,852 KB |
最終ジャッジ日時 | 2024-10-12 14:16:49 |
合計ジャッジ時間 | 1,969 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Collections.Generic; using System.Linq; using System; public class Hello { public static void Main() { var a = Console.ReadLine().Trim().ToArray(); var ans = getAns(a); Console.WriteLine(ans); } public static int getAns (char[] a) { var aL = a.Length; var ans = new List<int>(); ans.Add(int.Parse(new string(a))); for (int i = 0; i < aL; i++) for (int j = i + 1; j < aL; j++) { swap(a, i, j); var t = new string(a); ans.Add(int.Parse(t)); swap(a, i, j); } return ans.Max(); } public static void swap (char[] a, int n , int m) { var w = a[n]; a[n] = a[m]; a[m] = w; } }