Hdu4651 (Theorem-water)

Source: Internet
Author: User

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 ;}

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.