From f7f5e29bee4df17dac9d20be667446426785767f Mon Sep 17 00:00:00 2001 From: oncsr Date: Thu, 6 Mar 2025 09:47:22 +0900 Subject: [PATCH] =?UTF-8?q?[20250306]=20BOJ=20/=20P4=20/=20My=EB=B7=B0=20?= =?UTF-8?q?=EA=BE=B8=EB=AF=B8=EA=B8=B0=20/=20=EA=B6=8C=ED=98=81=EC=A4=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0 \352\276\270\353\257\270\352\270\260.md" | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 "khj20006/202503/06 BOJ P4 My\353\267\260 \352\276\270\353\257\270\352\270\260.md" diff --git "a/khj20006/202503/06 BOJ P4 My\353\267\260 \352\276\270\353\257\270\352\270\260.md" "b/khj20006/202503/06 BOJ P4 My\353\267\260 \352\276\270\353\257\270\352\270\260.md" new file mode 100644 index 00000000..2893ce6f --- /dev/null +++ "b/khj20006/202503/06 BOJ P4 My\353\267\260 \352\276\270\353\257\270\352\270\260.md" @@ -0,0 +1,72 @@ +```java + +import java.util.*; +import java.io.*; + +class Main { + + // IO field + static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); + static StringTokenizer st; + + static void nextLine() throws Exception {st = new StringTokenizer(br.readLine());} + static int nextInt() {return Integer.parseInt(st.nextToken());} + static long nextLong() {return Long.parseLong(st.nextToken());} + static void bwEnd() throws Exception {bw.flush();bw.close();} + + // Additional field + + static int N; + static long ans = 1; + static long[] fac = new long[600001]; + static final long mod = (long)1e9 + 7; + + + public static void main(String[] args) throws Exception { + + ready(); + solve(); + + bwEnd(); + + } + + static void ready() throws Exception{ + + N = Integer.parseInt(br.readLine()); + fac[0] = 1; + for(int i=1;i<=600000;i++) fac[i] = (fac[i-1] * i) % mod; + + } + + static void solve() throws Exception{ + + while(N-- > 0) { + nextLine(); + int a = nextInt(), b = nextInt(); + ans = (ans * (comb(a+b,a) + mod - 1)) % mod; + } + bw.write(ans + "\n"); + + } + + static long comb(int x, int y) { + + return fac[x] * power(fac[x-y], mod-2) % mod * power(fac[y], mod-2) % mod; + + } + + // x^p % mod + static long power(long x, long p) { + if(p == 0) return 1; + if(p == 1) return x % mod; + long half = power(x,p>>1) % mod; + half = half * half % mod; + if(p%2==0) return half; + return half * x % mod; + } + +} + +```