結果
問題 | No.39 桁の数字を入れ替え |
ユーザー |
![]() |
提出日時 | 2015-11-28 08:43:40 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,323 bytes |
コンパイル時間 | 3,352 ms |
コンパイル使用メモリ | 78,580 KB |
実行使用メモリ | 52,948 KB |
最終ジャッジ日時 | 2024-09-14 04:36:36 |
合計ジャッジ時間 | 5,760 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 WA * 9 |
ソースコード
package yukicoder; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class yukicoder014 { public static void main(String[] args){ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String tes = null; try { tes = br.readLine(); } catch (IOException e) { // TODO 自動生成された catch ブロック e.printStackTrace(); } char[] tmpq = tes.toCharArray(); char[] tmps = tes.toCharArray(); char jie = 0; for(int i=0;i<tmps.length;i++){ for(int j=0;j<tmps.length;j++){ if(tmps[i] > tmps[j]){ jie = tmps[i]; tmps[i] = tmps[j]; tmps[j] = jie; } } } String asdf = ""; String as = ""; for(int i= 0;i<tmps.length;i++){ if(tmpq[i] != tmps[i]){ asdf = asdf + tmpq[i]; }else{ as = as + tmpq[i]; } } char[] tmp = asdf.toCharArray(); char s = '1'; int num = -1; for(int i = 0;i<tmp.length;i++){ if(tmp[i] >= s){ s = tmp[i]; num = i; } } char aaa = 0; for(int i = 0;i<tmp.length;i++){ if(num == 0){ break; } if(tmp[i] < s){ aaa = tmp[i]; tmp[i] = s; tmp[num] = aaa; break; } } System.out.println(as+String.copyValueOf(tmp)); } }