fork download
  1. import java.util.Scanner;
  2. import java.math.BigInteger;
  3.  
  4. class Main {
  5.  
  6. private static BigInteger [] f = new BigInteger[1801];
  7.  
  8. public static void getFat() {
  9. f[0] = BigInteger.ONE;
  10. for(int i = 1; i <= 1800; i++) {
  11. f[i] = f[i - 1].multiply(BigInteger.valueOf(i));
  12. }
  13. }
  14.  
  15. public static void main(String[] args) {
  16. Scanner in = new Scanner(System.in);
  17.  
  18. getFat();
  19. while (true) {
  20. int n, q;
  21. n = in.nextInt();
  22. q = in.nextInt();
  23.  
  24. if (n == 0 && q == 0) break;
  25.  
  26. if (n >= 1800) {
  27. System.out.println("descartado");
  28. continue;
  29. }
  30. BigInteger c = f[n-q+1];
  31. BigInteger d = in.nextBigInteger();
  32.  
  33. if (c.compareTo(d) == 1) {
  34. System.out.println("descartado");
  35. } else {
  36. System.out.println(c);
  37. }
  38. }
  39. }
  40. }
Success #stdin #stdout 0.12s 3359744KB
stdin
4 1
100
5 2
30
6 3
10
0 0
stdout
24
24
descartado