问题描述
- 这个可以精确e的1000次代码的算法是什么意思
-
int main() { const int N = 1000; int a[N]; int s = 1; for (int n = N; n >= 1; --n) { int r = s % n; s = s / n + 1; for (int i = 0; i < N; ++i) { r = r * 10 + a[i]; a[i] = r / n; r %= n; } for (int i = N - 1; i > 0; --i) { a[i - 1] += a[i] / 10; a[i] %= 10; } s += a[0] / 10; a[0] %= 10; } printf("%d.", s); for (int i = 0; i < N; ++i) printf("%d", a[i]); printf("n"); return 0; }
时间: 2024-11-29 10:11:41