设计一个算法计算1方-2方+3方-4方+……+99方-100方的值,并画出程序框图!! 15
先证明一个数列定理
令Ef[n] = f[n + 1], Δf[n] = f[n + 1] - f[n]
那么Δf[n] = Ef[n] - f[n],Δf[n] = (E - 1)f[n]
即Δ = E - 1
故f[n] = E^nf[0] = (Δ + 1)^nf[0] = ΣC(n,k)Δ^kf[0],证毕
a[0] = 1^2 = 1, a[1] = 1^2 + 3^2 = 10, a[2] = 10 + 5^2 = 35 a[4] = 35 + 7^2 = 84
Δ^0a[0] = 1; Δ^1a[0] = 9; Δ^2a[0] = 16; Δ^3a[0] = 8, Δ^ka[0] = 0(k > 3)
所以a[n] = n(n-1)(n-2)*4/3 + 8n^2 + n + 1
b[0] = 2^2 = 4, b[1] = 2^2 + 4^2 = 20 b[2] = 20 + 6^2 = 56 b[4] = 56 + 8^2 = 120
Δ^0b[0] = 4; Δ^1b[0] = 16; Δ^2b[0] = 20; Δ^3b[0] = 8, Δ^kb[0] = 0(k > 3)
所以b[n] = n(n-1)(n-2)*4/3 + 10n^2 + 6n + 4
a[n] - b[n] = -(2n^2 + 5n + 3),带入49,结果是-5050
写程序的流程就是
output -5050
over
没有比这个更优的解了,编程需要的是正确的结果以及足够迅速!!!