結果
問題 | No.420 mod2漸化式 |
ユーザー |
![]() |
提出日時 | 2016-11-17 08:36:21 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 1,846 bytes |
コンパイル時間 | 151 ms |
コンパイル使用メモリ | 24,960 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-26 03:11:56 |
合計ジャッジ時間 | 1,296 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 35 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:49:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 49 | scanf("%d", &x); | ^~~~~~~~~~~~~~~
ソースコード
#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;}