mirror of
https://github.com/m1ngsama/code4sk.git
synced 2025-12-25 02:56:17 +00:00
31 lines
367 B
C++
31 lines
367 B
C++
/*
|
|
7-7 ?e????
|
|
?? 10
|
|
?? C???
|
|
?? ????
|
|
???? e ????? 1+1/1!+1/2!+?+1/n!+? ?????????????????? n,?????? n+1 ???
|
|
|
|
????:
|
|
???????????? n(=1000)?
|
|
|
|
????:
|
|
???????????,?????????
|
|
|
|
????:
|
|
10
|
|
????:
|
|
2.71828180
|
|
*/
|
|
|
|
#include<stdio.h>
|
|
int main(){
|
|
int n;
|
|
scanf("%d",&n);
|
|
double sum=1.0,tag=1.0;
|
|
for(int i=1;i<=n;i++){
|
|
tag=tag*1.0/i;
|
|
sum+=tag;
|
|
}
|
|
printf("%.8lf",sum);
|
|
return 0;
|
|
}
|