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);
}

  

上一篇:org.apache.jasper.JasperException: /WEB-INF/jsp/add.jsp(40,24) quote symbol expected


下一篇:JQuery版评分控件