Problem:
Score : 500 points

Problem Statement

Takahashi and Aoki will play a game. They will repeatedly play it until one of them have N wins in total.

When they play the game once, Takahashi wins with probability A %, Aoki wins with probability B %, and the game ends in a draw (that is, nobody wins) with probability C %.
Find the expected number of games that will be played, and print it as follows.

We can represent the expected value as P/Q with coprime integers P and Q.
Print the integer R between 0 and 10^9+6 (inclusive) such that R \times Q \equiv P\pmod {10^9+7}.
(Such an integer R always uniquely exists under the constraints of this problem.)

Constraints

1 \leq N \leq 100000

0 \leq A,B,C \leq 100

1 \leq A+B

A+B+C=100

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N A B C

Output

Print the expected number of games that will be played, in the manner specified in the statement.

Sample Input 1

1 25 25 50

Sample Output 1

2

Since N=1, they will repeat the game until one of them wins.
The expected number of games played is 2.

Sample Input 2

4 50 50 0

Sample Output 2

312500008

C may be 0.

Sample Input 3

1 100 0 0

Sample Output 3

1

B may also be 0.

Sample Input 4

100000 31 41 28

Sample Output 4

104136146

Solution in Common Lisp (SBCL 1.1.14) (judge verdict: Runtime Error)

#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))

#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                                          "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                                          "--eval" "(push :child-sbcl *features*)"
                                          "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))

(defparameter +mod+ (+ (expt 10 9) 7))

(defun mod+(&rest exp)
  (reduce (lambda (a b)
            (mod (+ a b) +mod+))
          exp))

(defun mod-(&rest exp)
  (reducce (lambda (a b)
             (mod (- a b) +mod+))
           exp))

(defun mod*(&rest exp)
  (reduce (lambda (a b)
            (mod (* a b) +mod+))
          exp))

(defun modpow (x y);x^y
  (if (zerop y) 1
      (mod* (if (oddp y) x 1)
            (modpow (mod* x x) (ash y -1)))))

(defun modinv (x)
  (modpow x (- +mod+ 2)))

(defun mod/(&rest exp)
  (reduce (lambda (a b)
            (mod (* a (modinv b)) +mod+))
          exp))

(defparameter N_MAX 100010)

(defvar factorial-memo (make-array N_MAX :initial-element nil))
(defvar factorial-inv-memo (make-array N_MAX :initial-element nil))
(defun factorial (x)
  (if (<= x 1) 1
      (if (aref factorial-memo x)
          (aref factorial-memo x)
          (setf (aref factorial-memo x) (mod* x (factorial (1- x)))))))

(defun factorial-inv (x)
  (if (= x (1- N_MAX))
      (modinv (factorial x))
      (if (aref factorial-inv-memo x)
          (aref factorial-inv-memo x)
          (setf (aref factorial-inv-memo x) (mod* (1+ x) (factorial-inv (1+ x)))))))

(defun combination (a b)
  (mod* (factorial a) (factorial-inv b) (factorial-inv (- a b))))

(defun main (n a b c)
  (let*
      ((need-one-win (mod/ 100 (- 100 c)))
       (win-a-p (mod/ a (+ a b)))
       (win-b-p (mod/ b (+ a b)))
       (ans 0))
    (dotimes (i n)
      (let* ((turn (+ n i))
             (way (combination (1- turn) i)))
        (setf ans (mod+ ans
                        (mod* turn need-one-win way
                              (modpow win-a-p n)
                              (modpow win-b-p i))))
        (setf ans (mod+ ans
                        (mod* turn need-one-win way
                              (modpow win-b-p n)
                              (modpow win-a-p i))))))
    (write ans)))


(main (read) (read) (read) (read))