結果

問題 No.411 昇順昇順ソート
ユーザー Daigo HIROOKA
提出日時 2018-07-03 01:34:20
言語 Java
(openjdk 23)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 409 bytes
コンパイル時間 3,397 ms
コンパイル使用メモリ 80,228 KB
実行使用メモリ 54,252 KB
最終ジャッジ日時 2024-07-01 01:51:40
合計ジャッジ時間 9,295 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class No411{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();
		if(k == 1){
			System.out.println(aasort(n));
		}else{
			System.out.println((int)Math.pow(2, n-k));
		}
	}
	private static int aasort(int n){
		if(n == 2){
			return 0;
		}else{
			return (int)Math.pow(2, n-2)-1 + aasort(n-1);
		}
	}
}
0