Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 이중우선순위큐
- Navier-Stokes
- 디스크 컨트롤러
- regression
- 통계학
- 유체역학
- Statistics
- 프로젝트오일러
- Blasius
- Fluid Dynamics
- projecteuler
- 프로그래머스
- heap
- 회귀
- FTCS
- programmers
- 힙
- Boundary Layers
- Heat Equation
- 예제
- Compressible Flow
- 우선순위큐
- Python
- Finite Difference Method
- 파이썬
- Turbulent
- Fluids
- Crank-Nicolson
- Laminar
- python3
Archives
- Today
- Total
Sudal's Garage
Project Euler 9 본문
Question:
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a2 + b2 = c2
For example, 32 + 42 = 9 + 16 = 25 = 52.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
문제:
다음 피타고라스 정리를 만족하면서 a < b < c 관계를 만족하는 세 자연수 a, b, c를 피타고라스 수라고 부른다.
a2 + b2 = c2
예를 들어, 32 + 42 = 9 + 16 = 25 = 52 가 있다.
a + b + c = 1000를 만족하면서 피타고라스 수인 세 자연수가 유일하게 존재한다. 그 수들의 곱 abc의 값을 구하여라.
Solution:
1 2 3 4 5 6 7 8 9 10 11 12 | isit = False for c in range(1,1000): for b in range(1,c): a = 1000 - c - b if a < b and b < c and a < c: if a ** 2 + b ** 2 == c ** 2: isit = True print('a: {}\nb: {}\nc: {}\nproduct: {}'.format(a,b,c,a*b*c)) if isit == True: break if isit == True: break | cs |
'Programming > Project Euler - python' 카테고리의 다른 글
Project Euler 11 (0) | 2019.02.26 |
---|---|
Project Euler 10 (0) | 2019.02.16 |
Project Euler 8 (0) | 2019.02.05 |
Project Euler 6 (0) | 2019.01.30 |
Project Euler 5 (0) | 2019.01.30 |