結果

問題 No.820 Power of Two
ユーザー tenten
提出日時 2020-11-12 11:56:07
言語 Java
(openjdk 23)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 483 bytes
コンパイル時間 2,265 ms
コンパイル使用メモリ 74,676 KB
実行使用メモリ 41,816 KB
最終ジャッジ日時 2024-07-22 19:10:21
合計ジャッジ時間 4,121 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

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