結果

問題 No.39 桁の数字を入れ替え
ユーザー kano_townkano_town
提出日時 2014-11-21 19:29:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 149 ms / 5,000 ms
コード長 560 bytes
コンパイル時間 3,369 ms
コンパイル使用メモリ 74,476 KB
実行使用メモリ 56,260 KB
最終ジャッジ日時 2024-04-10 04:30:40
合計ジャッジ時間 6,804 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
54,220 KB
testcase_01 AC 149 ms
53,876 KB
testcase_02 AC 126 ms
54,136 KB
testcase_03 AC 123 ms
54,160 KB
testcase_04 AC 124 ms
54,192 KB
testcase_05 AC 123 ms
54,136 KB
testcase_06 AC 124 ms
54,028 KB
testcase_07 AC 125 ms
54,116 KB
testcase_08 AC 126 ms
54,256 KB
testcase_09 AC 128 ms
53,988 KB
testcase_10 AC 123 ms
53,948 KB
testcase_11 AC 127 ms
56,260 KB
testcase_12 AC 123 ms
53,916 KB
testcase_13 AC 122 ms
53,868 KB
testcase_14 AC 123 ms
53,956 KB
testcase_15 AC 111 ms
52,936 KB
testcase_16 AC 111 ms
52,676 KB
testcase_17 AC 122 ms
54,108 KB
testcase_18 AC 124 ms
54,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Yukicoder39 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		
		char buf;
		int max = Integer.parseInt(String.valueOf(c));
		for (int i = 0; i < c.length - 1; i++) {
			for (int j = i + 1; j < c.length; j++) {
				buf = c[i];
				c[i] = c[j];
				c[j] = buf;

				max = Math.max(max, Integer.parseInt(String.valueOf(c)));
				
				buf = c[i];
				c[i] = c[j];
				c[j] = buf;

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