結果

問題 No.39 桁の数字を入れ替え
ユーザー 37zigen37zigen
提出日時 2016-05-01 23:40:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 143 ms / 5,000 ms
コード長 635 bytes
コンパイル時間 2,134 ms
コンパイル使用メモリ 75,160 KB
実行使用メモリ 54,512 KB
最終ジャッジ日時 2024-04-10 05:23:05
合計ジャッジ時間 5,469 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
54,080 KB
testcase_01 AC 130 ms
53,988 KB
testcase_02 AC 132 ms
53,928 KB
testcase_03 AC 131 ms
54,320 KB
testcase_04 AC 130 ms
54,064 KB
testcase_05 AC 131 ms
54,108 KB
testcase_06 AC 129 ms
54,044 KB
testcase_07 AC 130 ms
54,108 KB
testcase_08 AC 132 ms
54,344 KB
testcase_09 AC 127 ms
54,200 KB
testcase_10 AC 129 ms
54,200 KB
testcase_11 AC 133 ms
53,968 KB
testcase_12 AC 131 ms
54,280 KB
testcase_13 AC 131 ms
54,000 KB
testcase_14 AC 129 ms
54,156 KB
testcase_15 AC 134 ms
54,092 KB
testcase_16 AC 131 ms
53,884 KB
testcase_17 AC 131 ms
53,904 KB
testcase_18 AC 143 ms
54,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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);
	}
}
0