n probability of each count and occurrence of dice--dynamic planning

Source: Internet
Author: User

Title: The n Dice on the floor. All points of the dice on the upward side and one s. Enter n, the probability of printing s all possible values.

Statement ideas are not original! Just because the use of dynamic planning ideas is very good, write down.

Analysis: Dynamic planning is a phased consideration of issues. Give the variable. Find the relationship between adjacent phases. A detailed definition to forget.

1. Now the variables are: Dice number, points and.

When there is a K-dice. Points and is n. The number of occurrences is recorded as F (k,n). What is the relationship between that and the k-1 dice phase?

2. When I have k-1 a dice. Add another dice, the dice can only be 1, 2, 3, 4, 5 or 6. The case that K dice get points and for N is:

(k-1,n-1): K Dice Cast points 1

(k-1,n-2): K Dice Cast points 2

(k-1,n-3): K Dice Cast points 3

....

(k-1,n-6): K Dice Cast points 6

On the basis of k-1 dice, adding a dice to the number of points and the result of n is only 6 cases.

So:f (k,n) =f (k-1,n-1) +f (k-1,n-2) +f (k-1,n-3) +f (k-1,n-4) +f (k-1,n-5) +f (k-1,n-6)

3. There are 1 dice, f (=f) =f (1,3) =f (1,4) =f (1,5) =f (1,6) = 1.


The code is easy to write, recursive functions, returns, and the number of occurrences of N. Total sum of occurrences is 6^n.

http://zhedahht.blog.163.com/blog/#m =0

Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.

n probability of each count and occurrence of dice--dynamic planning

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.