結果

問題 No.39 桁の数字を入れ替え
コンテスト
ユーザー 37zigen
提出日時 2016-05-01 23:40:00
言語 Java
(openjdk 26.0.2.1 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
AC  
実行時間 55 ms / 5,000 ms
+ 981µs
コード長 635 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,655 ms
コンパイル使用メモリ 86,380 KB
実行使用メモリ 45,372 KB
最終ジャッジ日時 2026-09-08 16:47:53
合計ジャッジ時間 4,297 ms
ジャッジサーバーID
(参考情報)
<nil> / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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