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
- FTCS
- Boundary Layers
- Finite Difference Method
- 이중우선순위큐
- Laminar
- Heat Equation
- Fluid Dynamics
- Crank-Nicolson
- heap
- Fluids
- regression
- 유체역학
- Blasius
- 통계학
- 디스크 컨트롤러
- programmers
- Compressible Flow
- python3
- projecteuler
- 예제
- 프로젝트오일러
- Turbulent
- Statistics
- 힙
- 우선순위큐
- Navier-Stokes
- 프로그래머스
- 파이썬
- 회귀
- Python
Archives
- Today
- Total
Sudal's Garage
Project Euler 40 본문
Question:
An irrational decimal fraction is created by concatenating the positive integers:
0.123456789101112131415161718192021...
It can be seen that the 12th digit of the fractional part is 1.
If dn represents the nth digit of the fractional part, find the value of the following expression.
d1 × d10 × d100 × d1000 × d10000 × d100000 × d1000000
문제:
양의 정수를 순서대로 이어붙여서 다음과 같은 무리수를 만들 수 있다.
0.123456789101112131415161718192021...
위 수의 소수점 12번째 자리 숫자는 1이다.
dn이 위 수의 소수점 n번째 자리 숫자라고 할 때, 다음을 구하여라.
d1 × d10 × d100 × d1000 × d10000 × d100000 × d1000000
Solution:
import time digits = [0] i = 1 start = time.time() while len(digits) < 1000001: for x in range(len(str(i))): digits.append(int(list(str(i))[x])) i += 1 result = digits[1] * digits[10] * digits[100] * digits[1000] * digits[10000] * digits[100000] * digits[1000000] print("result = {0}\nFound in ...{1:.3f}s".format(result,time.time() - start))
설명할 게 없는 무난한 코드
0.8초 걸렸다.
'Programming > Project Euler - python' 카테고리의 다른 글
Project Euler 42 (0) | 2019.04.04 |
---|---|
Project Euler 41 (0) | 2019.04.03 |
Project Euler 39 (0) | 2019.04.01 |
Project Euler 38 (0) | 2019.03.31 |
Project Euler 37 (0) | 2019.03.30 |