結果

問題 No.420 mod2漸化式
ユーザー iicafiaxus
提出日時 2016-09-09 22:52:23
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 535 bytes
コンパイル時間 1,475 ms
コンパイル使用メモリ 165,292 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-12 04:15:30
合計ジャッジ時間 2,474 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	int x = readln.chomp.to!int;
	
	BigInt ans1, ans2;
	
	if(x > 31){
		ans1 = 0;
		ans2 = 0;
		}
	else{
		ans1 = binom(31, x);
		ans2 = ans1 * x * 2147483647 / 31;
		}
	
	writeln(ans1, " ", ans2);
	}

BigInt binom(int n, int k){
	BigInt x = 1;
	for(int i = 1; i <= n; i ++) x *= i;
	for(int i = 1; i <= k; i ++) x /= i;
	for(int i = 1; i <= n - k; i ++) x /= i;
	
	return x;
	}
0