結果

問題 No.39 桁の数字を入れ替え
ユーザー k_kadorak_kadora
提出日時 2015-06-22 23:25:35
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 614 bytes
コンパイル時間 6,417 ms
コンパイル使用メモリ 72,256 KB
実行使用メモリ 57,852 KB
最終ジャッジ日時 2023-09-21 23:48:50
合計ジャッジ時間 9,714 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,756 KB
testcase_01 AC 124 ms
55,384 KB
testcase_02 AC 126 ms
55,424 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 123 ms
55,588 KB
testcase_08 AC 124 ms
55,592 KB
testcase_09 AC 124 ms
55,744 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 125 ms
55,968 KB
testcase_15 AC 122 ms
55,828 KB
testcase_16 AC 121 ms
55,884 KB
testcase_17 AC 125 ms
55,704 KB
testcase_18 AC 128 ms
53,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Yuki39{
	public static void main(String[] arg){
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		String s;
		int max=0,pos=0;
		s = sc.next();
		sb.append(s);
		int[] n = new int[10];
		for(int i = 0;i<s.length();i++){
			n[Character.getNumericValue(s.charAt(i))]++;
		}
		for(int i = 0;i<10;i++){
			if(n[i] > 0)max = i;
		}
		for(int i = 0;i<s.length();i++){
			if(Character.getNumericValue(s.charAt(i)) == max)pos = i;
		}
		sb.setCharAt(pos,s.charAt(0));
		sb.replace(0,1,Integer.toString(max));
		System.out.println(sb.toString());
	}
}
0