Test Instructions:Link
Method:The Division of Numbers
parsing:I finally got a problem with this!! century Old PIT!!!!!! First of all, I admit that this thing is violent and I can't write. Or a violent explosion of complexity.
Look at this picture above, this is a 7*7 matrix obviously he can be represented by 2,2,3 (RT), but the representation of the three matrices it divides here must be unique. What is unique? A matrix of side length 4 is shown. There are obviously two kinds of filling schemes. Such as.
But the first filling scheme is obviously made up of two matrices with a 2 side length, not his unique scheme. The second fill scenario is its unique fill scheme, because in this fill scenario. Cannot find a size of I (I because if I can find a size of I (I now our purpose is to seek the number of unique schemes of size n matrices.) After a lengthy drawing process =-= found that only the following scenarios are unique, and that a matrix of length n (n>=2) has only one unique scheme.
As for proving .... (Dare to guess!) Careful hypothesis! Never prove it! So the problem becomes water, since the arbitrary length n matrix (n>=2) has only one unique scheme. So this problem becomes a scheme that divides n into a bunch of numbers greater than or equal to 2 (this 1 is its exclusive solution). Direct O (n^2) preprocessing partitioning scheme number can be. In addition, the inertial pit! Take the remainder is 1e8+7 not 1e9+7!!!!!!!!
Code:
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define N#define MOD 100000007using namespace STD;typedef Long LongllintT,n;intf[ .][ .];voidInit () {f[0][0]=1; for(intI=1; i<= -; i++) { for(intj=1; j<=i;j++) {if(F[i-j][j]) f[i][j]= (f[i-1][j-1]+F[I-J][J])%mod;Elsef[i][j]=f[i-1][j-1]; } }}intMain () {init ();scanf("%d", &t); while(t--) {scanf("%d", &n);if(n==1){puts("0");Continue;}if(n==2){puts("1");Continue;}if(n==3){puts("1");Continue;}intans=0; for(intI=2; i<=n/2; i++) {ans= (ans+f[n-i][i])%mod; }printf("%d\n", ans+1); }}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
JDFZ 1112 The division of the number of the senior building