fork download
  1. import static java.lang.Math.*;
  2. import static java.util.Arrays.*;
  3.  
  4. public class FoxMakingDiceEasy {
  5.  
  6. int N, K;
  7.  
  8. public int theCount(int N, int K) {
  9. this.N = N;
  10. this.K = K - 2;
  11. int ret = 0;
  12. for (int i = 0; i < N; i++)
  13. for (int j = i + 1; j < N; j++)
  14. for (int k = j + 1; k < N; k++)
  15. ret += count(i, j, k);
  16. return ret * 2;
  17. }
  18.  
  19. int count(int i, int j, int k) {
  20. int ret = 0;
  21. loop: for (int s = max(K, k * 2 + 1); s < 2 * N; s++) {
  22. int[] is = { i, j, k, s - i, s - j, s - k };
  23. sort(is);
  24. if (is[5] >= N)
  25. break;
  26. for (int n = 0; n < 5; n++)
  27. if (is[n] == is[n + 1])
  28. continue loop;
  29. ret++;
  30. }
  31. return ret;
  32. }
  33. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty