SGU130 Circle

SGU130 Circle

题目大意

将圆周上的2K个点两两连接,将圆分割为最少数量的弧
问连接方案数与最少的数量分别为多少

算法思路

不难发现,连接出来的K条弦在不相交的情况下,把圆分解为K+1条圆弧,是数量最少的方案
而方案数则是卡特兰数的经典实例,资料很多这里就不多做解释了

时间复杂度: O(K)

代码

/**
 * Copyright © 2015 Authors. All rights reserved.
 * 
 * FileName: 130.cpp
 * Author: Beiyu Li <sysulby@gmail.com>
 * Date: 2015-06-13
 */
#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)

typedef long long LL;
typedef pair<int, int> Pii;

const int inf = 0x3f3f3f3f;
const LL infLL = 0x3f3f3f3f3f3f3f3fLL;

int main()
{
        int k;
        scanf("%d", &k);
        LL c = 1;
        For(i,1,k) c = c * (4 * i - 2) / (i + 1);
        printf("%I64d %d\n", c, k + 1);

        return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值