結果

問題 No.39 桁の数字を入れ替え
ユーザー shinshin
提出日時 2022-05-31 19:11:26
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 957 bytes
コンパイル時間 3,469 ms
コンパイル使用メモリ 80,116 KB
実行使用メモリ 53,744 KB
最終ジャッジ日時 2023-10-21 00:43:39
合計ジャッジ時間 5,486 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
53,664 KB
testcase_01 AC 54 ms
53,744 KB
testcase_02 AC 51 ms
53,724 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 53 ms
53,716 KB
testcase_08 AC 55 ms
53,732 KB
testcase_09 AC 54 ms
53,720 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 52 ms
52,620 KB
testcase_15 AC 52 ms
53,724 KB
testcase_16 AC 52 ms
53,660 KB
testcase_17 AC 52 ms
53,740 KB
testcase_18 AC 51 ms
53,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class No39 {

	public static void main(String[] args) throws IOException{
		//桁の数字を入れ替え
		String str = readStr()[0] , s;
		String[] N = str.split("") , clone;
		int max = Integer.parseInt(str);
		
		for(int i = 1;i < N.length;i++) {
			clone = N.clone();
			s = clone[i];
			clone[i] = clone[0];
			clone[0] = s;
			
			str = "";
			for(String c : clone) {
				str += c;
			}
			max = Math.max(max, Integer.parseInt(str));
		}
		
		System.out.println(max);
		
		
		

	}
	
	public static String[] readStr() throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<String> list = new ArrayList<>();

		do {
			list.add(br.readLine());
		}while(br.ready());

		br.close();

		String[] text = new String[list.size()];
		list.toArray(text);

		return text;

	}

}
0