Language: Java

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        private static long MOD = (long) (1e9 + 7);
        int N;
        int A;
        int B;
        int C;
        static int MAX = 400000;
        static long xs = new long[MAX + 1];
        static long ys = new long[MAX + 1];

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            N = in.nextInt();
            A = in.nextInt();
            B = in.nextInt();
            C = in.nextInt();

            long ret = 0;
            long Awin = A * modpow(A + B, MOD - 2) % MOD;
            long Bwin = B * modpow(A + B, MOD - 2) % MOD;
            long num = (A + B + C) * modpow(A + B, MOD - 2) % MOD;

            for (int i = 0; i <= N - 1; i++) {
                ret += comb(N - 1 + i, i) * modpow(Awin, N) % MOD * modpow(Bwin, i) % MOD * (N + i) % MOD;
                ret += comb(N - 1 + i, i) * modpow(Bwin, N) % MOD * modpow(Awin, i) % MOD * (N + i) % MOD;
            }
            out.println(ret % MOD * num % MOD);
        }

        private long comb(int n, int r) {
            if (r < 0 || r > n) return 0;

            if (xs[0] == 0) {
                xs[0] = 1;
                for (int i = 1; i <= MAX; i++) {
                    xs[i] = xs[i - 1] * i % MOD;
                }
                long inv = modpow(xs[MAX], MOD - 2);
                ys[MAX] = inv;
                for (int i = MAX; i >= 1; i--) {
                    inv = inv * i % MOD;
                    ys[i - 1] = inv;
                }
            }

            return xs[n] * (ys[r] * ys[n - r] % MOD) % MOD;
        }

        private long modpow(long a, long n) {
            long r = 1;
            while (n > 0) {
                r = r * ((n % 2) != 0 ? a : 1) % MOD;
                a = a * a % MOD;
                n >>= 1;
            }
            return r;
        }

    }
}



Compiler output:
Main.java:29: error: incompatible types: long[] cannot be converted to long
        static long xs = new long[MAX + 1];
                         ^
Main.java:30: error: incompatible types: long[] cannot be converted to long
        static long ys = new long[MAX + 1];
                         ^
Main.java:53: error: array required, but long found
            if (xs[0] == 0) {
                  ^
Main.java:54: error: array required, but long found
                xs[0] = 1;
                  ^
Main.java:56: error: array required, but long found
                    xs[i] = xs[i - 1] * i % MOD;
                      ^
Main.java:56: error: array required, but long found
                    xs[i] = xs[i - 1] * i % MOD;
                              ^
Main.java:58: error: array required, but long found
                long inv = modpow(xs[MAX], MOD - 2);
                                    ^
Main.java:59: error: array required, but long found
                ys[MAX] = inv;
                  ^
Main.java:62: error: array required, but long found
                    ys[i - 1] = inv;
                      ^
Main.java:66: error: array required, but long found
            return xs[n] * (ys[r] * ys[n - r] % MOD) % MOD;
                     ^
Main.java:66: error: array required, but long found
            return xs[n] * (ys[r] * ys[n - r] % MOD) % MOD;
                              ^
Main.java:66: error: array required, but long found
            return xs[n] * (ys[r] * ys[n - r] % MOD) % MOD;
                                      ^
12 errors