Http://acm.nyist.net/JudgeOnline/problem.php? PID = 90

Source: Internet
Author: User
Integer Division time limit: 3000 MS | memory limit: 65535 KB difficulty: 3
Description
Represent positive integer N as the sum of a series of positive integers: N = N1 + N2 +... + NK,
Among them, N1 ≥ N2 ≥... ≥ Nk ≥ 1, k ≥ 1.
This expression of positive integer N is called the division of positive integer n. N is not a positive integer.
Same number of partitions.
For example, positive integer 6 has the following 11 different classifications:
6;
5 + 1;
4 + 2, 4 + 1 + 1;
3 + 3, 3 + 2 + 1 + 1 + 1;
2 + 2 + 2 + 2 + 1 + 1 + 1 + 1 + 1 + 1 + 1;
1 + 1 + 1 + 1 + 1 + 1.

Input
The first line is the number of test data M (1 <= m <= 10 ). Each of the following lines contains an integer N (1 <=n <= 10 ).
Output
Number of methods for outputting each group of test data.
Sample Input
16
Sample output
 
11
 
Construct F (n, m) to represent N, and the maximum number of adders is M.
 
1> when either N or M is smaller than 1, the result must be 0.
 
2> when any one of N and M is 1, the result is certainly 1, because N is 1 and only 1, and m is 1 ,,,,
 
3.> when m is greater than N, you must modify the maximum number of Addons.
 
4> If M is equal to N, it can be converted to n-1 and add only itself...
 
5> when n is greater than m, it can be converted to M and M ..
ACCode
 
# Include <stdio. h> # include <string. h> int F (int x, int y) {If (x <1 | Y <1) return 0; If (x = 1 | Y = 1) return 1; if (x <Y) return f (x, x); If (x = y) return f (x, Y-1) + 1; return f (x, y-1) + f (x-y, Y);} int main () {int t; scanf ("% d", & T); While (t --) {int N; scanf ("% d", & N); printf ("% d \ n", F (n, 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.