51nod1201 Integer Division

Source: Internet
Author: User

01 The backpack obviously timed out. Then there is a god DP. DP[I][J] represents the number of schemes in which J number consists of I. O (NSQRT (n))

#include <cstdio> #include <cstring> #include <cctype> #include <algorithm>using namespace std; #define REP (I,s,t) for (int. i=s;i<=t;i++) #define DWN (i,s,t) for (int i=s;i>=t;i--) const int NMAX=5E4+5;CONST int MOD =1e9+7;int Dp[nmax][355];int Main () {int n;scanf ("%d", &n);DP [1][1]=1;rep (I,2,n) Rep (J,1,min (i,350)) dp[i][j]= (DP [I-j] [j]+dp[i-j][j-1])%mod;int ans=0;rep (i,1,350) ans= (Ans+dp[n][i])%mod;printf ("%d\n", ans); return 0;}

  

1201 integer Dividing base time limit: 1 seconds space limit: 131072 KB score: 80 Difficulty: 5-level algorithm collection attention to divide n into a number of different integers and, how many different ways, such as: n = 6,{6} {1,5} {2,4} {three-way}, a total of 4. Due to the large data, output mod 10^9 + 7 results. Input
Enter 1 number n (1 <= n <= 50000).
Output
Output divided by the number mod 10^9 + 7.
Input example
6
Output example
4

51nod1201 Integer Division

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.