P4746 C ' s problem (c)

Source: Internet
Author: User

Time: 1000ms/Space: 655360kib/java class name: main background

Winter School Entrance Test

Describe

Title Description

Small C is a mathematician, because of its poor self-control, often all night to study mathematical problems.

This time it is because of this mathematics question already two days two nights not to sleep, do not study out will be deadly! Help IT, please!

The problem is this, there is a number n, splitting it into the sum of several natural numbers, the product is the largest!

If you think the problem is just that simple, then you are too naive.

Because small c challenges their own self-cultivation, it stipulates that the natural number 22 must not be equal!

It asked you to output the maximum number of this product, but the answer is too big, little C is not interested in looking at such a long number, it just want to know this number of 1000000007 modulo value is how much.

Input format

One line of a number means n

Output format

A number means an answer.

Note

Input sample

6

Output sample

8

Data range

For data n<=10 of 30%.

For data n<=10000 of 50%.

For data 1<=n<=1000000000 of 100%.

1 #defineLL Long Long2 3#include <iostream>4 using namespacestd;5 6 ConstLL mod=1000000007;7LL n,num=2, ans=1;8LL a[100010],s=0;9 Ten intMain () One { ACin>>N; -     if(n<=5) -     { thecout<<n<<Endl; -         return 0; -     } -      while(n>=num) +     { -n-=num; +a[++s]=num; Anum++; at     } -      while(n>0) -     { -          for(inti=s;i>=1; i--) -             if(n>0) -             { ina[i]++; -n--; to             } +     } -      for(intI=1; i<=s;i++) theAns= (Ans*a[i])%MoD; *cout<<ans<<Endl; $     return 0;Panax Notoginseng}

P4746 C ' s problem (c)

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.