結果
問題 |
No.420 mod2漸化式
|
ユーザー |
|
提出日時 | 2016-09-10 01:28:40 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 184 ms / 1,000 ms |
コード長 | 764 bytes |
コンパイル時間 | 5,948 ms |
コンパイル使用メモリ | 77,452 KB |
実行使用メモリ | 42,720 KB |
最終ジャッジ日時 | 2024-12-24 11:28:53 |
合計ジャッジ時間 | 11,725 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 35 |
ソースコード
package No400番台; import java.math.BigInteger; import java.util.Scanner; public class Q420 { public static void main(String[] args) { new Q420().solver(); } void solver() { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); if (x >= 32) { System.out.println(0 + " " + 0); } else { BigInteger comb = new BigInteger("1"); for (int i = 31; i >= Math.max(31 - x, x) + 1; i--) { comb = comb.multiply(BigInteger.valueOf(i)); } for (int i = Math.min(31 - x, x); i >= 1; i--) { comb = comb.divide(BigInteger.valueOf(i)); } BigInteger sum = BigInteger.valueOf((1L << 31) - 1); sum=sum.multiply(comb.multiply(BigInteger.valueOf(x)).divide(BigInteger.valueOf(31))); System.out.println(comb + " " + sum); } } }