等比数列求和

如果公比为2,有k个元素:
Sk = 20+21+22+23+...+2k-1

2(Sk) = 2(20+21+22+23+...+2k-1)

21+22+23+...+2k-1+2k

得:

Sk = 2(S1) - S1 = 2k-20 = 2k-1

通用推导:

设公比为q

Sn = a1+a2+a3+...+an

= a1 + a1q + a1q2+a1q3+...+a1qn-1

qSn = a1q + a1q2+a1q3+...+a1qn-1+a1qn

qSn- Sn = a1qn-a1

Sn = a1(qn-1)/(q-1)

再回头让q=2,a1=1,带入翻过来验证:

Sn = 2n-1

时间: 2024-10-25 16:06:03

等比数列求和的相关文章

hoj3152-Dice 等比数列求和取模

http://acm.hit.edu.cn/hoj/problem/view?id=3152 Dice My Tags (Edit) Source : Time limit : 1 sec Memory limit : 128 M Submitted : 82, Accepted : 18 You have a dice with M faces, each face contains a distinct number. Your task is to calculate the expect

[NOI2011] 兔农 矩阵乘法,矩阵的等比数列求和

#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; typedef long long ll; ll n,p; ll k; #define N 4000000 ll a[N],fr[N]; struct sq{ ll a[3][3]; sq(){memset(a,0,sizeof(a));} sq operator*(sq

等比数列求和公式

[等比数列求和公式] 首项a1,公比q a(n+1)=an*q=a1*q^(n Sn=a1+a2+..+an q*Sn=a2+a3+...+a(n+1) qSn-Sn=a(n+1)-a1 S=a1(q^n-1)/(q-1)

bzoj 4555 [Tjoi2016&amp;Heoi2016]求和 NTT 第二类斯特林数 等比数列求和优化

[Tjoi2016&Heoi2016]求和 Time Limit: 40 Sec  Memory Limit: 128 MBSubmit: 679  Solved: 534[Submit][Status][Discuss] Description 在2016年,佳媛姐姐刚刚学习了第二类斯特林数,非常开心. 现在他想计算这样一个函数的值: S(i, j)表示第二类斯特林数,递推公式为: S(i, j) = j ∗ S(i − 1, j) + S(i − 1, j − 1), 1 <= j &l

B-Icebound and Sequence(等比数列求和取模)

题目传送门:B-Icebound and Sequence(19年河北省赛) 题目大意: 等比数列求和,结果取模 分析: 因为取模操作,直接运用等比数列求和公式无法做出,所以需要用到公式 求等比为k的等比数列之和S[n]..当n为偶数..S[n] = S[n/2] + pow(k,n/2) * S[n/2] n为奇数...S[n] = S[n/2] + pow(k,n/2) * S[n/2] + pow(k,n)等比数列第n个数的值 代码: #include<bits/stdc++.h> us

题解:2018级算法第一次练习赛 等比数列求和

问题描述: 样例: 实现解释: 这里等比数列求和使用到的知识点包括:分治和快速幂 其中分治的方法和快速幂的方法是从博客中学习到的: 等比数列分治求和:https://blog.csdn.net/qq_35937273/article/details/82750298 快速幂方法:https://www.cnblogs.com/lca1826/p/6748372.html 结合到本题目中可参考完整代码. 在分治求和和快速幂之外取模操作的实现解释如下: 根据描述可知最后的值是很大的,所以需要取余,但

Sumdiv 等比数列求和

Sumdiv Sumdiv Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 15364   Accepted: 3790 Description Consider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine S modulo 9901 (the rest of the division of

[zoj 3774]Power of Fibonacci 数论(二次剩余 拓展欧几里得 等比数列求和)

Power of Fibonacci Time Limit: 5 Seconds      Memory Limit: 65536 KB In mathematics, Fibonacci numbers or Fibonacci series or Fibonacci sequence are the numbers of the following integer sequence: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, .

[hdu 4959]Poor Akagi 数论(卢卡斯数,二次域运算,等比数列求和)

Poor Akagi Time Limit: 30000/15000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 131    Accepted Submission(s): 29 Problem Description Akagi is not only good at basketball but also good at math. Recently, he got a

hdu 4990(数学,等比数列求和)

Reading comprehension Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1270    Accepted Submission(s): 512 Problem Description Read the program below carefully then answer the question.#pragma co