結果
問題 | No.420 mod2漸化式 |
ユーザー |
![]() |
提出日時 | 2019-05-09 19:38:22 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 511 bytes |
コンパイル時間 | 184 ms |
コンパイル使用メモリ | 29,056 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-02 00:51:16 |
合計ジャッジ時間 | 1,323 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 35 |
ソースコード
// yukicoder: No.420 mod2漸化式 // 2019.5.9 bal4u #include <stdio.h> long long tbl[35][35]; long long combi(int n, int k) { long long ans; if (tbl[n][k]) return tbl[n][k]; if ((k << 1) > n) k = n-k; if (k == 0) ans = 1; else if (k == 1) ans = n; else ans = combi(n-1, k) + combi(n-1, k-1); return tbl[n][k] = ans; } int main() { int x; scanf("%d", &x); if (x == 0) puts("1 0"); else if (x > 31) puts("0 0"); else printf("%lld %lld\n", combi(31, x), 2147483647LL*combi(30, x-1)); return 0; }