코딩놀이! 10 Days of Statistics(HackerRank)
Day 4 -4: Geometric Distribution II
12 번째 문제!
Objective In this challenge, we go further with geometric distributions. We recommend reviewing the Geometric Distribution tutorial before attempting this challenge. Task Input Format The first line contains the respective space-separated numerator and denominator for the probability of a defect, and the second line contains the inspection we want the probability of the first defect being discovered by:
If you do not wish to read this information from stdin, you can hard-code it into your program. Output Format Print a single line denoting the answer, rounded to a scale of decimal places (i.e., format). |
방금 전 문제랑 정말 똑같네요 ㅎㅎ 간단히 풀고 패스!!!!!!!
불량품! 확률 구하기ㅜㅜ 지루..
문제해석!
1. 불량 확률 1/3(이공장망하겟네요)
2. 5개에서 불량이 나올 확률
계산식 포인트
Math.Pow( 1-DEFECTIVE_PROBABILITY, i )*DEFECTIVE_PROBABILITY;
1. (모든확률-불량확률)pow(몇번?)*불량확률 이 답이겟네요
*5번째까지 정상 확률과 마지막은 불량이나올확률 곱하기하는겁니당*
그럼 코드공개!
class Solution { private static readonly double DEFECTIVE_PROBABILITY = (double)1/3; private static readonly int FOUND_DEFECTIVE = 5; static void Main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */ Console.Write(probability2()); } static string probability2(){ double result=0.0; for(int i=0; i < FOUND_DEFECTIVE; i++;) { result += Math.Pow( 1 - DEFECTIVE_PROBABILITY, i) * DEFECTIVE_PROBABILITY; } return string.Format("{0:0.000}",result); } }
ㅠㅠ 감사 드디어 별하나 득템ㅠㅠ 이제 하나만 더따면!!!!!!!!!!!!!!!!!!후...그럼이만
4일차 4문제중 4개 Clear!!!!!!!
그럼이만! 혹시 설명이 부족하다면 댓글 달아주세용 ㅎ
(출처:https://www.hackerrank.com/challenges/s10-geometric-distribution-2/problem)