結果
問題 | No.39 桁の数字を入れ替え |
ユーザー |
|
提出日時 | 2016-05-01 23:40:00 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 136 ms / 5,000 ms |
コード長 | 635 bytes |
コンパイル時間 | 2,076 ms |
コンパイル使用メモリ | 74,376 KB |
実行使用メモリ | 41,836 KB |
最終ジャッジ日時 | 2024-10-02 06:56:06 |
合計ジャッジ時間 | 5,396 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
ソースコード
package yukicoder; import java.util.Scanner; public class Main{ public static void main(String[] args)throws Exception{ new Main().solve(); } void solve(){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int ans=n; for(int i=0;i<String.valueOf(n).length();i++){ for(int j=i+1;j<String.valueOf(n).length();j++){ int d=n; int dumy=d/(int)Math.pow(10, i)%10; d=d-dumy*(int)Math.pow(10, i); int dumy2=d/(int)Math.pow(10, j)%10; d=d-dumy2*(int)Math.pow(10, j); d+=(int)Math.pow(10, i)*dumy2; d+=(int)Math.pow(10, j)*dumy; ans=Math.max(ans, d); } } System.out.println(ans); } }