시그마 (0 -> 9) 가 i일때, 1 / i! 들의 합을 구하는것
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
/** | |
* https://www.acmicpc.net/problem/6376 | |
* BOJ 백준온라인져지 6376 e 계산 풀이 | |
*/ | |
int main(){ | |
printf("n e\n"); | |
printf("- -----------\n"); | |
printf("0 1\n"); | |
printf("1 2\n"); | |
printf("2 2.5\n"); | |
double factorial = 2; | |
double i = 2; | |
double result = 2.5; | |
while(factorial < 9){ | |
factorial++; | |
i *= factorial; | |
result += 1 / i; | |
printf("%.0f %.9f\n", factorial, result); | |
} | |
} |
'IT > 알고리즘' 카테고리의 다른 글
BOJ 백준온라인져지 6359 만취한 상범 풀이 (0) | 2017.12.11 |
---|---|
BOJ 백준온라인져지 6378 디지털 루트 풀이 (0) | 2017.12.11 |
BOJ 백준온라인져지 2217 로프 풀이 (0) | 2017.12.10 |
BOJ 백준온라인져지 1931 회의실배정 풀이 (0) | 2017.12.09 |
BOJ 백준온라인져지 13241 최소공배수 풀이 (0) | 2017.12.08 |