See the Pentagon theorem ..
Http://en.wikipedia.org/wiki/Partition _
The reciprocal of the Euler's function is the primary function of the split function, that is:
The generation function of is
-
(1)
-
Again
Use the Pentagon Number Theorem to obtain the following expansions:
-
(2)
-
Add the (2) type to the (1) type and multiply it to the left of the (1) type to expand and merge the same category items. The coefficient of the number of items is 0 !!
-
The generated function is used together with the Pentagon Number Theorem to obtain the following recursive relationship.
-
# Include <cstdio> # include <iostream> # include <cstdlib> # include <algorithm> # include <cmath> # include <string> # include <cstring> # include <set> # include <map> # include <list> # include <queue> # include <vector> # define tree int o, int l, int r # define lson o <1, l, mid # define rson o <1 | 1, mid + 1, r # define lo o <1 # define ro o <1 | 1 # define ULL unsigned long # define LL long # define UI unsigned int # define inf 0x7fffffff # defi Ne eps 1e-7 # define M 1000000007 # define N 100001 using namespace std; int T, n, m, k, t, maxv; LL p [N]; void init () // {p [0] = p [1] = 1; for (int I = 2; I <N; I ++) {for (int j = 1, k = 1; j ++, k =-k) {int s = j * (j * 3-1)/2; if (I-s> = 0) p [I] = (p [I] + p [I-s] * k) % M; else break; s = j * (j * 3 + 1)/2; if (I-s> = 0) p [I] = (p [I] + p [I-s] * k) % M; else break ;} while (p [I] <0) p [I] + = M; // WA !!! Negative value} int main () {# ifndef ONLINE_JUDGE freopen ("ex. in "," r ", stdin); # endif int ncase = 0; scanf (" % d ", & T); init (); // while (scanf ("% d", & n) = 1) while (T --) {scanf ("% d", & n ); printf ("% I64d \ n", p [n]);} return 0 ;}