8635 balloons, 2920838635

Source: Internet
Author: User

8635 balloons, 2920838635

  8635 balloons

This question has an answer

Time Limit: 500 MS memory limit: 1000 K
Submissions: 204 passed: 58

Question type: Programming Language: G ++; GCC

 

Description
One day, OYY came back from the game and took many balloons in his hand, with different colors. When he saw me, he said, you see, I took a lot of balloons! I worship the dead !! Then he asked me a question, if the balloon here is divided into several parts. How many methods are there? I am dizzy because I am very fond of mathematics, so I hope you can help me solve this problem (@_@))



Input Format
There are two rows of input data with two numbers n and m, representing the number of balloons on oyy and the number of parts (n <= 10, m <= 5) 2nd rows have m numbers, representing the number of each copy, ensuring that the total number is equal to n


Output Format
One row of output data indicates the total number of different methods.


 

Input example
3 13


 

Output example
1


 

Prompt
Sample Input2:4 22 2Sample Output2:3


 

Source Ick2

 

Author admin

Using the average mathematical distribution principle, the data array does not end with '\ 0'

1 # include <stdio. h> 2 # include <stdlib. h> 3 int main () 4 {5 int n, m, a [5], B [15] = {0}, I, j, x, top; 6 scanf ("% d", & n, & m); 7 for (I = 0; I <m; I ++) 8 {scanf ("% d", & a [I]); B [a [I] + = 1;} 9/* for (I = 0; I <m; I ++) 10 printf ("% d", a [I]); 11 printf ("\ n"); */12 13 int sum1 = 1; 14 for (I = 0; I <m; I ++) 15 {16 top = a [I]; 17 for (j = 0; j <top; j ++) 18 sum1 = sum1 * (n-j); 19 20 n = n-a [I]; 21} 22 for (I = 0; I <m; I ++) 23 {24 top = a [I]; 25 for (j = 0; j <top; j ++) 26 sum1 = sum1/(top-j ); 27 n = n-a [I]; 28} 29 30 31 32 for (I = 0; I <m; I ++) 33 {34 for (j = I + 1; j <m; j ++) 35 {36 if (a [j] = a [I]) 37 {a [j] = 0; 38 continue;} 39} 40} 41 42 43 x = 0; 44 for (I = 0; I <m; I ++) 45 {46 if (a [I] = 0) 47 {48 I ++; 49 continue; 50} 51 else52 {53 a [x] = a [I]; 54 x ++; 55 I ++;} 56} 57 58/* for (I = 0; I <x; I ++) 59 printf ("% d ", a [I]); 60 printf ("\ n"); */61 62 int sum2 = 1; 63 for (I = 0; I <x; I ++) 64 {65 66 for (j = 0; j <B [a [I]; j ++) 67 {68 sum2 = sum2 * (B [a [I]-j); 69} 70} 71 72 printf ("% d", sum1/sum2 ); 73 return 0; 74}View Code

 

Related Article

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.