結果
問題 | No.420 mod2漸化式 |
ユーザー |
![]() |
提出日時 | 2020-10-14 11:22:53 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 164 ms / 1,000 ms |
コード長 | 804 bytes |
コンパイル時間 | 2,675 ms |
コンパイル使用メモリ | 76,956 KB |
実行使用メモリ | 42,424 KB |
最終ジャッジ日時 | 2024-07-20 19:02:55 |
合計ジャッジ時間 | 8,988 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 35 |
ソースコード
import java.util.*;public class Main {public static void main (String[] args) {Scanner sc = new Scanner(System.in);int x = sc.nextInt();if (x > 31) {System.out.println("0 0");return;}if (x == 0) {System.out.println("1 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][x];long sum = 0;for (int i = 0; i < 31; i++) {sum += (1L << i) * comb[30][x - 1];}System.out.println(count + " " + sum);}}