結果

問題 No.39 桁の数字を入れ替え
ユーザー shin
提出日時 2022-05-31 19:11:26
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 957 bytes
コンパイル時間 3,988 ms
コンパイル使用メモリ 80,288 KB
実行使用メモリ 52,752 KB
最終ジャッジ日時 2024-09-21 01:24:27
合計ジャッジ時間 6,239 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11 WA * 8
権限があれば一括ダウンロードができます

ソースコード

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