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("");
String m="";
while((m=br.readLine())!=null) {
String[]str=m.split(" ");
int x=Integer.parseInt(str[0]);
int y=Integer.parseInt(str[1]);
sb.append(c(x,y)).append("\n");
}
System.out.print(sb);
}
static int c(int n, int r) {
BigInteger ans = BigInteger.ONE;
r = Math.min(r, n - r);
for (int i = 1; i < r + 1; i++) {
ans = ans.multiply(BigInteger.valueOf(n - r + i));
ans =ans.divide(BigInteger.valueOf(i));
}
return (ans+"").length();
}
}
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("");
String m="";
while((m=br.readLine())!=null) {
String[]str=m.split(" ");
int x=Integer.parseInt(str[0]);
int y=Integer.parseInt(str[1]);
sb.append(c(x,y)).append("\n");
}
System.out.print(sb);
}
static int c(int n, int r) {
BigInteger ans = BigInteger.ONE;
r = Math.min(r, n - r);
for (int i = 1; i < r + 1; i++) {
ans = ans.multiply(BigInteger.valueOf(n - r + i));
ans =ans.divide(BigInteger.valueOf(i));
}
return (ans+"").length();
}
}
No comments:
Post a Comment