結果
問題 |
No.39 桁の数字を入れ替え
|
ユーザー |
|
提出日時 | 2015-11-03 16:27:55 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 129 ms / 5,000 ms |
コード長 | 639 bytes |
コンパイル時間 | 3,499 ms |
コンパイル使用メモリ | 74,912 KB |
実行使用メモリ | 41,628 KB |
最終ジャッジ日時 | 2024-10-02 06:47:10 |
合計ジャッジ時間 | 6,537 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
import java.util.Scanner; public class Main_yukicoder39 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); char[] n = sc.next().toCharArray(); int max = Integer.parseInt(new String(n)); for (int i = 0; i < n.length; i++) { for (int j = i + 1; j < n.length; j++) { char tmp = n[i]; n[i] = n[j]; n[j] = tmp; max = Math.max(max, Integer.parseInt(new String(n))); tmp = n[i]; n[i] = n[j]; n[j] = tmp; } } System.out.println(max); sc.close(); } }