Bzoj 3823 tokens of pledge recursion

Source: Internet
Author: User

The main idea: the definition point is 0-dimensional element, the line is a one-dimensional element, the surface is a two-dimensional element, the space is three-dimensional elements, and so on, to find the n-dimensional cube of the dimensions of the number of elements

F[I][J] is the number of J-dimension elements in the i-dimensional cubic body

Consider the i-dimensional elements in the n-dimensional cube, extending the n-dimensional cube to the n+1 dimension space (it is thought that the abstract conceivable plane expands into a cube)

The original I-dimensional element was increased by one time, while the original i-1 dimension element became an i-dimensional element

Therefore there is f[i][j]=f[i-1][j]*2+f[i-1][j-1]

After a series of derivation (I will not how to push, I am playing the table after the oblique looking regular), you can get f[i][j]=2^ (i-j) *c (I,J)

Then there is the f[n][i]=f[n][i+1]*2* (i+1)/(n-i) linearity to find the inverse from the backward forward can be

#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define M 10001000using namespace Std;long long inv[m],ans=1;int n,p;void linear_shaker () {    int i;    Inv[1]=1;    for (i=2;i<=n;i++)        inv[i]= (p-p/i) *inv[p%i]%p;} int main () {    int i;    a long long temp;    cin>>n>>p;    Linear_shaker ();    Temp=1;    for (i=n-1;~i;i--)    {        temp=temp* (i+1<<1)%p*inv[n-i]%p;        ans^=temp;    }    Cout<<ans<<endl;}


Bzoj 3823 tokens of pledge recursion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.