130. Circle time limit per test: 0.25 sec. 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 |
#include <bits/stdc++.h>
using namespace std;
long long v[35];
void solve(){
v[0]=1;
v[1]=1;
for(int i=2;i<=30;i++){
for(int j=0;j<i;j++){
v[i]+=v[j]*v[i-j-1];
}
}
int n;
scanf("%d",&n);
printf("%lld %d",v[n],n+1);
}
int main(){
solve();
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long v[35];
void solve(){
v[1]=1;
for(int i=2;i<=30;i++){
v[i]=v[i-1]*(4*i-2)/(i+1);
}
int n;
scanf("%d",&n);
printf("%lld %d",v[n],n+1);
}
int main(){
solve();
return 0;
}
import java.math.BigInteger;
import java.util.Scanner;
public class Main{
public static void main(String[] arg){
Scanner cin= new Scanner(System.in);
BigInteger a[] = new BigInteger[35];
a[1]=BigInteger.ONE;
for(int i=2;i<=30;i++){
a[i]=a[i-1].multiply(BigInteger.valueOf(4*i-2)).divide(BigInteger.valueOf(i+1));
}
int x;
x=cin.nextInt();
System.out.println(a[x]+" "+(x+1));
}
}