Liverpool will play against a certain team n number of times in a tournament. A match can end with 3 possible results: win, loss or tie, and each outcome is equally likely. Write a C program to calculate the probability that there will be exactly k number of wins for Liverpool. Note: After submission in HackerRank, you have to upload the program (c file) on eduserver. Program filename must be RollNo_2.c (without any blank space). Input Format The inputs to the program are two positive integers: n and k (separated by a space) Constraints k<=n Output Format The output of the program is a float value representing the probability Sample Input 0 2 1 Sample Output 0 0.444444 Explanation 0 Here, n=2 and k=1. So, all possible outcomes: WW, WL, LW, LL, WT, TW, TT, LT, TL (W indicates win, L indicates loss, and T indicates tie). In this case, the number of outcomes having exactly 1 win: 4. Hence, the probability is 4/9=0.444444 which is the output.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Liverpool will play against a certain team n number of times in a tournament. A match can end with 3 possible results: win, loss or tie, and each outcome is equally likely. Write a C program to calculate the probability that there will be exactly k number of wins for Liverpool.

Note: After submission in HackerRank, you have to upload the program (c file) on eduserver. Program filename must be RollNo_2.c (without any blank space).

Input Format

The inputs to the program are two positive integers: n and k (separated by a space)

Constraints

k<=n

Output Format

The output of the program is a float value representing the probability

Sample Input 0

2 1

Sample Output 0

0.444444

Explanation 0

Here, n=2 and k=1. So, all possible outcomes: WW, WL, LW, LL, WT, TW, TT, LT, TL (W indicates win, L indicates loss, and T indicates tie). In this case, the number of outcomes having exactly 1 win: 4. Hence, the probability is 4/9=0.444444 which is the output.

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Stack operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education