結果
問題 | No.39 桁の数字を入れ替え |
ユーザー |
![]() |
提出日時 | 2015-05-03 15:14:59 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 53 ms / 5,000 ms |
コード長 | 1,003 bytes |
コンパイル時間 | 3,458 ms |
コンパイル使用メモリ | 81,948 KB |
実行使用メモリ | 37,316 KB |
最終ジャッジ日時 | 2024-10-02 06:20:39 |
合計ジャッジ時間 | 5,070 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
import java.io.BufferedReader; import java.io.InputStreamReader; public class No039 { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader( System.in)); String S = br.readLine(); int N = Integer.parseInt(S); int max = N; int Slength = S.length(); char[] c; char tmp; int newN = 0; for (int j = 0; j < Slength; j++) { for (int i = j + 1; i < Slength; i++) { c = S.toCharArray(); tmp = c[i]; c[i] = c[j]; c[j] = tmp; newN = Integer.parseInt(String.copyValueOf(c)); max = Math.max(max, newN); } } System.out.println(max); } catch (Exception e) { System.err.println("Error:" + e.getMessage()); } } }