結果

問題 No.420 mod2漸化式
ユーザー suppy193suppy193
提出日時 2016-11-17 08:36:21
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 1,846 bytes
コンパイル時間 764 ms
コンパイル使用メモリ 27,676 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 00:42:59
合計ジャッジ時間 2,127 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 0 ms
4,384 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 0 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 0 ms
4,380 KB
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,384 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 0 ms
4,380 KB
testcase_19 AC 0 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 0 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 0 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 0 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <math.h>

int fact(int n)
{
	if(n == 0)return 1;
	return n * fact(n - 1);
}


int combi(int n, int k)
{
	return fact(n) / fact(n - k) / fact(k);
}

int sum(int m, int n)
{
	//printf("m = %d n = %d\n", m, n);
	if(m < n)return 0;
	if(m == 1 && n == 1)return 1;
	if(n == 0)return 0;
	return sum(m - 1, n) + sum(m - 1, n - 1) + combi(m - 1, n - 1) * pow(2, m - 1);
	
}

long long int p2(int n)
{
	int i;
	long long int ans = 1; 
	for(i = 1;i <= n;i++){
		ans *= (long long int)2;
	}
	return ans;
	
}

int main(void) {
	long long int s[50][50] = {0};
	long long int f[40] = {0};
	long long int c[50][50] = {0};
	int i, j;
	int m, n;
	int x;
	//printf("%d\n", fact(5));
	//printf("%d\n", combi(7, 5));
	//printf("%d\n", sum(4, 2));
	//printf("%lld\n", 58851789346035);
	
	scanf("%d", &x);
	if(x > 32){
		printf("0 0\n");
		return 0;
	}
	f[0] = 1;
	for(i = 1;i <= 32;i++){
		f[i] = (long long int)i * f[i - 1];
		
	}
	//printf("%lld\n", f[20]);

	c[0][0] = 1;
	for(i = 1;i <= 32;i++){
		c[i][0] = 1;
		for(j = 1;j <= 32;j++){
			c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
			//printf("%lld ", c[i][j]);
		}
		//printf("\n");
	}
	
	
	for(m = 1;m <= 33;m++){
		for(n = 1;n <= m;n++){
			//printf("m = %d n = %d\n", m, n);
			//s[m][n] = s[m - 1][n] + s[m - 1][n - 1] + combi(m - 1, n - 1) * pow(2, m - 1);
			//s[m][n] = s[m - 1][n] + s[m - 1][n - 1] + f[m - 1] / f[n - 1] / f[m - n] * p2(m - 1);
			s[m][n] = s[m - 1][n] + s[m - 1][n - 1] + c[m - 1][n - 1] * p2(m - 1);
			//printf("%d ", s[m][n]);
		}
	}
	
	//printf("%lld\n", s[4][2]);
	//printf("%lld\n", s[31][1]);
	//printf("%lld\n", s[31][2]);
	//printf("%lld\n", s[31][3]);
	//printf("%lld\n", s[31][4]);
	//printf("%lld %lld\n", c[31][5], s[31][5]);
	printf("%lld %lld\n", c[31][x], s[31][x]);
	//printf("%lld\n", p2(32));
	//printf("%lld\n", s[32][32]);
	
	return 0;
}
0