洛谷 P1044 栈(Catalan 数)
程序员文章站
2022-07-13 11:51:30
...
一、题目描述
二、算法分析说明
三、AC 代码
#include<cstdio>
#pragma warning(disable:4996)
__int128 n, x = 1;
int main() {
scanf("%llu", &n);
for (__int128 i = n + 1; i <= 2 * n; ++i)x *= i;
for (__int128 i = 2; i <= n; ++i)x /= i;
printf("%llu\n", x / (n + 1));
return 0;
}
#include<cstdio>
#pragma warning(disable:4996)
unsigned long long n, x = 1;
int main() {
scanf("%llu", &n);
for (unsigned long long i = 1; i <= n; ++i) { x *= i + n, x /= i; }
printf("%llu\n", x / (n + 1));
return 0;
}
上一篇: 洛谷日常:P1044 栈(1)
下一篇: P1044 栈(卡特兰数)