Topic Links: Click the open link
The non-incremental program first, the calculation,
If you do not increase the number of programs x, the non-reduction of some scenarios is X
The answer is 2*x-n.
Just need x to do it.
Can write a N3 DP first, and then found that the law is C (n-1, 2*n-1)
Then you can set an inverse.
#include <iostream> #include <cstdio> #include <vector> #include <string.h>using namespace std; #define LL Long long#define mod 1000000007ll n;ll Pow (ll x, ll y) { ll ans = 1; while (y) { if (y&1) ans = (ans * x)% mod; Y >>= 1; x = (x*x)%mod; } return ans;} ll Chu (ll X, ll y) { return (x * Pow (y, mod-2))%mod;} int main () {ll I, J;while (cin>>n) { if (n==1) {puts ("1"); continue;} N--; ll ans = n+2; ll zi = 2, mu = n+3; for (i = n+3; I <= 2*n+1; i++) { ans *= mu; ans = chu (ans% mod, zi); mu++; zi++; } Ans *= 2; Ans-= (n+1); Ans + = mod; Cout<<ans%mod<<endl;} return 0;}
Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.
Codeforces 57C Array dp violence Find patterns