結果

問題 No.820 Power of Two
ユーザー tentententen
提出日時 2020-11-12 11:56:07
言語 Java21
(openjdk 21)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 483 bytes
コンパイル時間 1,995 ms
コンパイル使用メモリ 71,640 KB
実行使用メモリ 56,356 KB
最終ジャッジ日時 2023-09-30 01:13:40
合計ジャッジ時間 3,712 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
56,076 KB
testcase_01 AC 115 ms
56,012 KB
testcase_02 AC 116 ms
54,392 KB
testcase_03 AC 116 ms
55,940 KB
testcase_04 AC 116 ms
56,068 KB
testcase_05 AC 116 ms
55,824 KB
testcase_06 AC 117 ms
56,356 KB
testcase_07 AC 117 ms
55,752 KB
testcase_08 AC 115 ms
55,868 KB
testcase_09 AC 116 ms
55,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        if (n < k) {
            System.out.println(0);
        } else {
            System.out.println(pow(2, n - k));
        }
    }
    
    static int pow(int x, int p) {
        if (p == 0) {
            return 1;
        } else {
            return x * pow(x, p - 1);
        }
    }
}
0