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)