結果
問題 | No.39 桁の数字を入れ替え |
ユーザー | shinwisteria |
提出日時 | 2017-04-01 10:05:16 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 132 ms / 5,000 ms |
コード長 | 639 bytes |
コンパイル時間 | 3,555 ms |
コンパイル使用メモリ | 76,168 KB |
実行使用メモリ | 54,380 KB |
最終ジャッジ日時 | 2024-04-10 05:43:22 |
合計ジャッジ時間 | 6,718 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 129 ms
54,188 KB |
testcase_01 | AC | 129 ms
54,156 KB |
testcase_02 | AC | 127 ms
54,144 KB |
testcase_03 | AC | 129 ms
54,004 KB |
testcase_04 | AC | 132 ms
54,160 KB |
testcase_05 | AC | 131 ms
54,268 KB |
testcase_06 | AC | 128 ms
53,852 KB |
testcase_07 | AC | 128 ms
54,236 KB |
testcase_08 | AC | 128 ms
54,020 KB |
testcase_09 | AC | 127 ms
54,160 KB |
testcase_10 | AC | 129 ms
54,232 KB |
testcase_11 | AC | 130 ms
54,052 KB |
testcase_12 | AC | 130 ms
54,056 KB |
testcase_13 | AC | 130 ms
54,104 KB |
testcase_14 | AC | 128 ms
54,044 KB |
testcase_15 | AC | 129 ms
54,152 KB |
testcase_16 | AC | 114 ms
53,000 KB |
testcase_17 | AC | 128 ms
54,380 KB |
testcase_18 | AC | 128 ms
53,864 KB |
ソースコード
import java.util.Scanner; public class Ketairekae { public static void main(String[] args) { Scanner s = new Scanner(System.in); StringBuilder str = new StringBuilder(s.nextLine()); s.close(); boolean tof = false; for(int j = 0;j < str.length()-1;j++){ for(int i = 9;i > Integer.parseInt(str.substring(j, j+1));i--){ String I = Integer.toString(i); if(str.lastIndexOf(I) > j){ int k = str.lastIndexOf(I); char keep = str.charAt(k); str.setCharAt(k, str.charAt(j)); str.setCharAt(j, keep); tof = true; break; } } if(tof){ break; } } System.out.println(str); } }