Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.math.BigInteger;
- import java.util.Scanner;
- public class E {
- public static void main(String[] args) {
- BigInteger[][] t = new BigInteger[65][10];
- BigInteger zero = BigInteger.ZERO;
- BigInteger one = BigInteger.ONE;
- for (int i = 0; i < t[0].length; i++) {
- t[0][i] = one;
- }
- for (int x = 0, y = 9; x < t.length - 1; y++) {
- if (y == 9) {
- BigInteger sum = zero;
- for (; y >= 0; y--) {
- sum.add(t[x][y]);
- }
- x++;
- t[x][0] = sum;
- y = 1;
- } else {
- t[x][y] = t[x][y-1].subtract(t[x-1][y-1]);
- }
- }
- Scanner sc = new Scanner(System.in);
- int p = sc.nextInt();
- for (int i = 1; i <= p; i++) {
- sc.nextInt();
- int d = sc.nextInt();
- System.out.println(i + " " + t[d][0]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement