結果
問題 | No.420 mod2漸化式 |
ユーザー |
![]() |
提出日時 | 2018-09-20 02:03:20 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 160 ms / 1,000 ms |
コード長 | 652 bytes |
コンパイル時間 | 3,039 ms |
コンパイル使用メモリ | 76,580 KB |
実行使用メモリ | 55,196 KB |
最終ジャッジ日時 | 2024-07-18 08:26:56 |
合計ジャッジ時間 | 9,478 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 35 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); long x = scan.nextLong(); scan.close(); if(x == 0) { System.out.println(1 + " " + 0); System.exit(0); } if(x > 31) { System.out.println(0 + " " + 0); }else { long c = comb(31, (int)x); long sum = ((long)Math.pow(2, 31) - 1) * comb(30, (int)x-1); System.out.println(c + " " + sum); } } static long comb(int n, int k) { if(n < k) { int t = n; n = k; k = t; } if(k == 0) { return 1; }else if(n == k) { return 1; }else { return comb(n - 1, k - 1) * n / k; } } }