UV 11021, uva11021

Source: Internet
Author: User

UV 11021, uva11021
Ultraviolet A 11021-Tribles

Question Link

The probability that each ball will be generated after death is pi. After m days, ask the probability that all the balls will die.

Train of Thought: f [I] is the probability of death on day I of a ball, so
F(I) =P0 +P1F(I− 1) +P2F(I− 1) 2 +... +PNF(I− 1)N

Then k fur balls use the multiplication theorem. The answer isF(M)K

Code:

# Include <stdio. h> # include <string. h> # include <math. h> const int n= 1005; int t, N, k, m; double p [n], f [N]; int main () {int cas = 0; scanf ("% d", & t); while (t --) {scanf ("% d", & n, & k, & m ); for (int I = 0; I <n; I ++) scanf ("% lf", & p [I]); f [0] = 0; f [1] = p [0]; for (int I = 2; I <= m; I ++) {f [I] = 0; for (int j = 0; j <n; j ++) f [I] + = p [j] * pow (f [I-1], j );} printf ("Case # % d: %. 7lf \ n ", ++ cas, pow (f [m], k);} 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.