Run ID Author Problem Lang Verdict Time Memory Code Length Submit Time
77649 sh25_wuyy 求出e的值 C++ Accepted 0 MS 248 KB 468 2025-12-26 14:35:38

Tests(1/1):


#include <iostream> #include <iomanip> using namespace std; int main() { int n; cin >> n; if (n < 2 || n > 15) { cout << "输入错误:n应该在2到15之间" << endl; return 1; } double e = 1.0; double factorial = 1.0; for (int i = 1; i <= n; i++) { factorial *= i; e += 1.0 / factorial; } cout << fixed << setprecision(10) << e << endl; return 0; }


Judgement Protocol: