結果

問題 No.39 桁の数字を入れ替え
ユーザー ぴろずぴろず
提出日時 2014-12-16 12:39:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 119 ms / 5,000 ms
コード長 575 bytes
コンパイル時間 2,048 ms
コンパイル使用メモリ 74,824 KB
実行使用メモリ 54,140 KB
最終ジャッジ日時 2024-04-10 04:33:48
合計ジャッジ時間 5,167 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
53,832 KB
testcase_01 AC 114 ms
53,800 KB
testcase_02 AC 100 ms
52,884 KB
testcase_03 AC 114 ms
54,072 KB
testcase_04 AC 108 ms
53,808 KB
testcase_05 AC 104 ms
52,632 KB
testcase_06 AC 113 ms
53,920 KB
testcase_07 AC 116 ms
54,140 KB
testcase_08 AC 111 ms
52,984 KB
testcase_09 AC 119 ms
53,948 KB
testcase_10 AC 108 ms
52,920 KB
testcase_11 AC 108 ms
53,568 KB
testcase_12 AC 114 ms
54,056 KB
testcase_13 AC 109 ms
53,336 KB
testcase_14 AC 116 ms
53,852 KB
testcase_15 AC 118 ms
54,012 KB
testcase_16 AC 108 ms
52,868 KB
testcase_17 AC 103 ms
52,956 KB
testcase_18 AC 114 ms
53,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no039;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int n = s.length;
		int max = Integer.valueOf(String.valueOf(s));
		for(int i=0;i<n;i++) {
			for(int j=i+1;j<n;j++) {
				swap(s, i, j);
				max = Math.max(max,Integer.valueOf(String.valueOf(s)));
				swap(s, i, j);
			}
		}
		System.out.println(max);
	}

	public static void swap(char[] a,int i,int j) {
		char temp = a[i];
		a[i] = a[j];
		a[j] = temp;
	}

}
0