0% found this document useful (0 votes)
51 views1 page

Problem - B - Codeforces

Uploaded by

De Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views1 page

Problem - B - Codeforces

Uploaded by

De Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

|

pythan | Logout
You have +145! Wow!

HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP

 Your password is extremely weak or has been leaked (see https://haveibeenpwned.com/). Please, change it ASAP.

PROBLEMS SUBMIT CODE MY SUBMISSIONS STATUS HACKS STANDINGS CUSTOM INVOCATION

Educational Codeforces Round


B. Binomial Coefficients, Kind Of 170 (Rated for Div. 2)

time limit per test: 2 seconds Finished


memory limit per test: 512 megabytes Practice
Recently, akshiM met a task that needed binomial coefficients to solve. He wrote a code he
usually does that looked like this:

for (int n = 0; n < N; n++) { // loop over n from 0 to N-1 → Virtual participation 
(inclusive)
Virtual contest is a way to take part in past
C[n][0] = 1;
contest, as close as possible to participation
C[n][n] = 1; on time. It is supported only ICPC mode for
for (int k = 1; k < n; k++) // loop over k from 1 to n-1 virtual contests. If you've seen these
problems, a virtual contest is not for you -
(inclusive) solve these problems in the archive. If you
C[n][k] = C[n][k - 1] + C[n - 1][k - 1]; just want to solve some problem from a
contest, a virtual contest is not for you -
}
solve this problem in the archive. Never use
Unfortunately, he made an error, since the right formula is the following: someone else's code, read the tutorials or
communicate with other person during a
virtual contest.
C[n][k] = C[n - 1][k] + C[n - 1][k - 1]
But his team member keblidA is interested in values that were produced using the wrong Start virtual contest
formula. Please help him to calculate these coefficients for t various pairs (ni , ki ). Note that
they should be calculated according to the first (wrong) formula.
→ Clone Contest to Mashup 
Since values C[ni ][ki ] may be too large, print them modulo 109 + 7.
You can clone this contest to a mashup.
Input
The first line contains a single integer t (1 ≤ t ≤ 105 ) — the number of pairs. Next, t pairs are Clone Contest
written in two lines.

The second line contains t integers n1 , n2 , … , nt (2 ≤ ni ≤ 105 ).


→ Submit?
The third line contains t integers k1 , k2 , … , kt (1 ≤ ki < ni ).
Language: GNU G++23 14.2 (64 bit, msys2)
Output
Print t integers C[ni ][ki ] modulo 109 + 7 . Choose
Choose File no file selected
file:

Example Submit
input Copy

7
2 5 5 100000 100000 100000 100000 → Problem tags
1 2 3 1 33333 66666 99999

output Copy combinatorics dp math


2 No tag edit access
4
8
2 → Contest materials
326186014
984426998
303861760 Announcement

Tutorial

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov

https://codeforces.com/contest/2025/problem/B 22/10/24, 1 54 PM
Page 1 of 2
:

You might also like