Solution to a problem - [yLOI2019] Tsing Sakura

Solution to a problem - [yLOI2019] original Green Sakura (mathematical combination)

The idea is quite good, and Oscar doubts a grade title


Portal: [yLOI2019] Tsing Sakura

Face questions

Description

Fusu is a very archaic people like to listen to pigeons and writing math problems, so this question is actually a five-Mihara title.

Buso hope to reproduce the original Green cherry blossom scenery, so he prepared a lot different from each other cherry tree seedlings, ready kind in a row.

In this line, a total of nn position can be planted cherry, and Fusu prepare mm branch seedlings. Because when in full bloom of cherry blossoms around the space requirement is very large, it is not next to the cherry cultivation, that is, there must be at least an empty place flowers between any two of the seedlings.

In this way gardening is not difficult, but so is a Fusu curious how many legitimate programs let him put down seedlings are planted mm branch. A program is legitimate if and only if he satisfies the requirements described in the previous paragraph. If we take according to 1, ~ 2, ~ 3 ~ \ dots ~ m1, 2, 3 ... m ID, two different schemes or different if and only if the selected flowers from the left position to the right of the sequence of numbers different number of flowers .

In order to avoid excessive output, a parameter of the answer modulo pp.

Input

And each input file has only one set of test data.
Only a row of four digital test data sequentially on behalf type, n, m, p, which is a type of test points help you determine the type of parameter, the range of data will be described in

Output

An output line number representing the result of the answer modulo p.

in.1
1 3 2 19260718

out.1
2

Data range and Conventions

Thinking

Consider each vacancy seedlings and behind him as an object, do the last position as a single case. In both cases multiplied! After summing m simplified for the sake of A (m, n-m + 1)

People worship the original author and the topic: Silver Pro.

Details are: A [yLOI2019] QingYuan Sakura

AC code:

#include<bits/stdc++.h>
using namespace std;
#define ll long long 
ll type , N , M , mod , ans = 1LL;
int main() {
  scanf("%lld%lld%lld%lld", &type , &N , &M , &mod ) ;
  ll tot = N - 2*M +1 ; 
  for( ll i = tot+1 ; i <= tot+M ; ++i )ans = i*ans%mod;
  cout<<ans ;
  return 0;
}

If insufficient, please indicate Gangster

Guess you like

Origin www.cnblogs.com/ssw02/p/11409179.html