結果

問題 No.256 桁の数字を入れ替え (2)
ユーザー YamaKasaYamaKasa
提出日時 2018-05-18 22:02:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 251 ms / 2,000 ms
コード長 662 bytes
コンパイル時間 2,131 ms
コンパイル使用メモリ 76,568 KB
実行使用メモリ 57,096 KB
最終ジャッジ日時 2023-09-10 22:55:59
合計ジャッジ時間 3,501 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,652 KB
testcase_01 AC 121 ms
55,604 KB
testcase_02 AC 249 ms
57,096 KB
testcase_03 AC 251 ms
56,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String N = scan.next();
		int []k = new int[10];
		Arrays.fill(k, 0);
		StringBuilder val = new StringBuilder();
		for(int i = 0; i < N.length(); i++) {
			char c = N.charAt(i);
			for(int j = 0; j < 10; j++) {
				if(j == Character.getNumericValue(c)) {
					k[j] ++;
				}
			}
		}
		scan.close();
		for(int i = 0; i < 10; i++) {
			if(k[9 - i] != 0) {
				String str = Integer.toString(9 - i);
				for(int j = 0; j < k[9 - i]; j++) {
					val.append(str);
				}
			}
		}
		System.out.println(val);
	}
}
0