結果

問題 No.420 mod2漸化式
コンテスト
ユーザー iicafiaxus
提出日時 2016-09-09 22:52:23
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 535 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,425 ms
コンパイル使用メモリ 141,388 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2026-03-05 07:24:50
合計ジャッジ時間 1,700 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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