Run ID Author Problem Lang Verdict Time Memory Code Length Submit Time
85120 sh25_shengmy 求出e的值 C++ Accepted 0 MS 248 KB 468 2026-03-06 15:04:19

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: