結果

問題 No.39 桁の数字を入れ替え
ユーザー GrenacheGrenache
提出日時 2015-11-03 16:27:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 129 ms / 5,000 ms
コード長 639 bytes
コンパイル時間 3,593 ms
コンパイル使用メモリ 75,752 KB
実行使用メモリ 54,492 KB
最終ジャッジ日時 2024-04-10 05:14:52
合計ジャッジ時間 6,557 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
53,844 KB
testcase_01 AC 127 ms
54,004 KB
testcase_02 AC 126 ms
53,992 KB
testcase_03 AC 124 ms
54,180 KB
testcase_04 AC 124 ms
53,996 KB
testcase_05 AC 129 ms
54,340 KB
testcase_06 AC 124 ms
54,064 KB
testcase_07 AC 125 ms
54,148 KB
testcase_08 AC 124 ms
54,236 KB
testcase_09 AC 125 ms
54,228 KB
testcase_10 AC 125 ms
54,148 KB
testcase_11 AC 123 ms
53,756 KB
testcase_12 AC 127 ms
54,416 KB
testcase_13 AC 124 ms
54,148 KB
testcase_14 AC 127 ms
54,084 KB
testcase_15 AC 125 ms
54,492 KB
testcase_16 AC 124 ms
53,984 KB
testcase_17 AC 124 ms
54,116 KB
testcase_18 AC 123 ms
54,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder39 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        char[] n = sc.next().toCharArray();

        int max = Integer.parseInt(new String(n));
        for (int i = 0; i < n.length; i++) {
        	for (int j = i + 1; j < n.length; j++) {
        		char tmp = n[i];
        		n[i] = n[j];
        		n[j] = tmp;
        		max = Math.max(max, Integer.parseInt(new String(n)));
        		 tmp = n[i];
        		n[i] = n[j];
        		n[j] = tmp;
        	}
        }

        System.out.println(max);
        
        sc.close();
    }
}
0