fork download
  1.  
  2. import java.io.*;
  3. import java.util.*;
  4.  
  5. public class CarefulWithPoison {
  6.  
  7. static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
  8. static StringTokenizer st = new StringTokenizer("");
  9.  
  10. public static String next() {
  11. try {
  12. while (!st.hasMoreTokens()) {
  13. String s = br.readLine();
  14. if (s == null)
  15. return null;
  16. st = new StringTokenizer(s);
  17. }
  18. return st.nextToken();
  19. } catch(Exception e) {
  20. return null;
  21. }
  22. }
  23. public static void main(String[] asda) throws Exception {
  24. int max = 2000000 + 10;
  25. fact = new long [max];
  26. fact[0] = fact[1] = 1;
  27. for (int k = 2; k < max; k++) {
  28. fact[k] = (k * fact[k-1]) % MOD;
  29. }
  30.  
  31. while (true) {
  32. int N = Integer.parseInt( next() );
  33. if (N == 0) {
  34. break;
  35. }
  36. int a = Integer.parseInt( next() );
  37. int b = Integer.parseInt( next() );
  38. long A = ways(N+N, N);
  39. long B = count(N, a+2, b);
  40. long C = count(N, a+1, b+1);
  41. long D = count(N, a, b+2);
  42.  
  43. long ans = (A - ((B+C+D)%MOD) + MOD) % MOD;
  44. out.println(ans);
  45. }
  46. //
  47. out.flush();
  48. System.exit(0);
  49. }
  50. static long [] fact;
  51. static long MOD = 1000000007;
  52.  
  53. static long count(int N, int a, int b) {
  54. return (ways(a+b, a) * ways(N - a + N - b, N - a)) % MOD;
  55. }
  56. static long ways(int N, int K) {
  57. long ans = fact[N] * modInverse( fact[K] );
  58. ans %= MOD;
  59. ans *= modInverse( fact[N-K] );
  60. return ans % MOD;
  61. }
  62.  
  63. static long modInverse(long x) {
  64. return modPow( x, MOD - 2, MOD );
  65. }
  66. static long modPow(long x, long pow, long mod) {
  67. long res = 1;
  68. while ( pow > 0 ) {
  69. if ( (pow&1) != 0 ) res = (res * x) % mod;
  70. pow >>= 1;
  71. x = (x*x) % mod;
  72. }
  73. return res;
  74. }
  75. }
  76.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:5: error: class CarefulWithPoison is public, should be declared in a file named CarefulWithPoison.java
public class CarefulWithPoison {
       ^
1 error
stdout
Standard output is empty