Poj 3734 Blocks

Source: Internet
Author: User

Poj_3734

This topic is 《ProgramAn example in the Integrated Mathematics in design. For an even number, this item can be written as (exp (x) + exp (-x)/2, if there is no requirement, you can write it as exp (x). By multiplying the four items, you can generate the function g (x) = (exp (4 * x) + 2 * exp (2 * X) + 1)/4, so x ^ N/(n !) The coefficient is (4 ^ n + 2*2 ^ N)/4, that is (2 ^ (n-1) + 1) * 2 ^ (n-1 ), then, use the Fast Power modulo to obtain the result.

# Include <stdio. h>
# Include < String . H>
# Define D 10007
Int Pow_mod ( Int N)
{
Int Ans;
If (N = 1 )
Return 2 ;
Ans = pow_mod (N/ 2 );
Ans = ans * ans % d;
If (N & 1 )
Ans = ans * 2 % D;
Return Ans;
}
Void Solve ()
{
Int I, j, k, n, ans;
Scanf ( " % D " , & N );
Ans = 1 ;
-- N;
If (N)
Ans = pow_mod (N );
Ans = (ANS + 1 ) * Ans % d;
Printf ( " % D \ n " , ANS );
}
Int Main ()
{
Int T;
Scanf ( " % D " , & T );
While (T --)
{
Solve ();
}
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.