zoukankan      html  css  js  c++  java
  • sgu 130Circle dp

    130. Circle

    time limit per test: 0.25 sec. 
    memory limit per test: 4096 KB

     

    On a circle border there are 2k different points A1, A2, ..., A2k, located contiguously. These points connect k chords so that each of points A1, A2, ..., A2k is the end point of one chord. Chords divide the circle into parts. You have to find N - the number of different ways to connect the points so that the circle is broken into minimal possible amount of parts P.

     

    Input

    The first line contains the integer k (1 <= k <= 30).

     

    Output

    The first line should contain two numbers N and P delimited by space.

     

    Sample Input

    2
    

    Sample Output

    2 3

    思路:选取一个固定点,比如P0点,然后分别和列举其他点Pj的连线,左边被分出j-1个点,右边则是i-j个点,左右分别是子图

    感想:考虑不周,以为只能和最左或者最下的连接,但是只要两边不互交就行了

    #include <cstdio>
    using namespace std;
    long long f[31];
    void calc(){
        f[0]=1;
        f[1]=1;
        f[2]=2;
        for(int i=3;i<31;i++){
            for(int j=1;j<=i;j++){
                f[i]+=f[j-1]*f[i-j];
            }
        }
    }
    int main(){
        int n;
        calc();
        scanf("%d",&n);
        printf("%I64d %d\n",f[n],n+1);
    }
    

      

  • 相关阅读:
    生产者消费者问题 一个生产者 两个消费者 4个缓冲区 生产10个产品
    三个线程交替数数 数到100
    c++ 字符串去重
    Java中一个方法只被一个线程调用一次
    GEF开发eclipse插件,多页编辑器实现delete功能
    python-arp 被动信息收集
    ssrf
    TCP
    xxe
    越权
  • 原文地址:https://www.cnblogs.com/xuesu/p/4020080.html
Copyright © 2011-2022 走看看