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