結果

問題 No.420 mod2漸化式
ユーザー tentententen
提出日時 2022-10-12 19:12:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 88 ms / 1,000 ms
コード長 1,590 bytes
コンパイル時間 3,590 ms
コンパイル使用メモリ 74,832 KB
実行使用メモリ 52,852 KB
最終ジャッジ日時 2023-09-08 18:37:06
合計ジャッジ時間 8,043 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
52,228 KB
testcase_01 AC 75 ms
52,592 KB
testcase_02 AC 76 ms
51,544 KB
testcase_03 AC 85 ms
52,284 KB
testcase_04 AC 79 ms
52,400 KB
testcase_05 AC 85 ms
52,220 KB
testcase_06 AC 76 ms
52,452 KB
testcase_07 AC 80 ms
52,288 KB
testcase_08 AC 74 ms
51,936 KB
testcase_09 AC 77 ms
52,360 KB
testcase_10 AC 86 ms
52,496 KB
testcase_11 AC 85 ms
52,348 KB
testcase_12 AC 79 ms
52,272 KB
testcase_13 AC 75 ms
52,396 KB
testcase_14 AC 78 ms
52,372 KB
testcase_15 AC 79 ms
52,356 KB
testcase_16 AC 76 ms
52,272 KB
testcase_17 AC 82 ms
52,324 KB
testcase_18 AC 82 ms
52,392 KB
testcase_19 AC 83 ms
52,756 KB
testcase_20 AC 75 ms
52,388 KB
testcase_21 AC 85 ms
52,500 KB
testcase_22 AC 76 ms
52,336 KB
testcase_23 AC 77 ms
52,484 KB
testcase_24 AC 81 ms
52,180 KB
testcase_25 AC 74 ms
51,044 KB
testcase_26 AC 78 ms
50,544 KB
testcase_27 AC 81 ms
52,236 KB
testcase_28 AC 88 ms
52,348 KB
testcase_29 AC 78 ms
52,852 KB
testcase_30 AC 76 ms
52,356 KB
testcase_31 AC 86 ms
52,676 KB
testcase_32 AC 86 ms
52,412 KB
testcase_33 AC 44 ms
49,272 KB
testcase_34 AC 43 ms
49,152 KB
testcase_35 AC 44 ms
51,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        if (n > 31) {
            System.out.println("0 0");
            return;
        }
        long[][] comb = new long[32][32];
        for (int i = 0; i < 32; i++) {
            for (int j = 0; j <= i; j++) {
                if (j == 0 || j == i) {
                    comb[i][j] = 1;
                } else {
                    comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
                }
            }
        }
        long count = comb[31][n];
        long total;
        if (n == 0) {
            total = 0;
        } else {
            total = ((1 << 31) - 1) * comb[30][n - 1];
        }
        System.out.println(count + " " + total);
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0