import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
BigInteger[] catlan = new BigInteger[37];
BigInteger[] fact = new BigInteger[73];
fact[0] = BigInteger.ONE;
fact[1] = BigInteger.ONE;
for (int i = 2; i < fact.length; i++) {
fact[i] = fact[i - 1].multiply(BigInteger.valueOf(i));
}
int oof = 0;
for (int i = 0; i < catlan.length; i++) {
catlan[i] = fact[2 * i].divide(fact[i + 1].multiply(fact[i]));
}
String m = "";
while ((m = br.readLine()) != null) {
int n = Integer.parseInt(m);
int ind = -1;
for (int i = 1; i < catlan.length; i++) {
if (BigInteger.valueOf(n).compareTo(catlan[i]) == 0) {
ind = i;
break;
}
}
sb.append(ind).append("\n");
}
System.out.print(sb);
}
}
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
BigInteger[] catlan = new BigInteger[37];
BigInteger[] fact = new BigInteger[73];
fact[0] = BigInteger.ONE;
fact[1] = BigInteger.ONE;
for (int i = 2; i < fact.length; i++) {
fact[i] = fact[i - 1].multiply(BigInteger.valueOf(i));
}
int oof = 0;
for (int i = 0; i < catlan.length; i++) {
catlan[i] = fact[2 * i].divide(fact[i + 1].multiply(fact[i]));
}
String m = "";
while ((m = br.readLine()) != null) {
int n = Integer.parseInt(m);
int ind = -1;
for (int i = 1; i < catlan.length; i++) {
if (BigInteger.valueOf(n).compareTo(catlan[i]) == 0) {
ind = i;
break;
}
}
sb.append(ind).append("\n");
}
System.out.print(sb);
}
}
No comments:
Post a Comment