728x90
수학적 접근으로 빨리 풀었다.
import sys
from itertools import combinations
import math
a = int(input())
b = int(input())
# 구간은 18개 존재
# 2,3,5,7,11,13,17
# 1 - 둘 다 소수가 아닌 경우
# 0,1,4,6,8,9,10,12,14,15,16,18
def check(possible, number):
# 18개 중에서 possible 확률로 number 만큼 뽑힐 경우
# ex) 18Cnumber * (possible의 number 제곱) * (1-possile)의 (18-number)제곱
return math.factorial(18)/( math.factorial(18-number))/ math.factorial(number) * possible**number * (1-possible)**(18-number)
answer1 = 0
answer2 = 0
no_sosu = [0,1,4,6,8,9,10,12,14,15,16,18]
for i in range(0,len(no_sosu)):
answer1 += check(a/100,no_sosu[i])
answer2 += check(b/100,no_sosu[i])
print(1-answer1*answer2)
728x90
'🟢 알고리즘 문제 풀이 > Baekjoon' 카테고리의 다른 글
| [파이썬] 백준 1563 개근상 (0) | 2023.05.16 |
|---|---|
| [파이썬] 백준 13397 구간 나누기 2 (1) | 2023.05.15 |
| [파이썬] 백준 9095 1, 2, 3 더하기 (0) | 2023.05.12 |
| [파이썬] 백준 17404 RGB2 (0) | 2023.05.11 |
| [파이썬] 백준 2631 줄 세우기 (0) | 2023.05.07 |