题解 1013: [编程入门]Sn的公式求和

来看看其他人写的题解吧!要先自己动手做才会有提高哦! 
返回题目 | 我来写题解

筛选

[编程入门]Sn的公式求和

摘要:解题思路:本题的关键是如何输出 2、22、222、2222 。认真思考后我们可以得出以下规律:2=0*10+222=2*10+2222=22*10+22222=222*10+2然后只看等号右面可以得到……

如何快速求和,看这里

摘要:解题思路:无注意事项:无参考代码:#include<stdio.h>#include<math.h>int main(){ int i,j,n; (void)scanf("%d",&n); int s……

Sn的公式求和

摘要:解题思路:注意到2222这种东西还是用字符串来操作比较简单,再用stoi函数让string转为int就好了。参考代码:#include<iostream>#include<string>using n……

Sn求和的方法

摘要:# Sn的公式求和 解题思路:sn=2+22+222+2222+22..2 可以发现规律an=2*10^(n-1)+an-1 代码: ``` #include #include in……

看清规律,速解Sn求和问题

摘要:解题思路:找规律,有n项,就有n个2,n-1个20,n-2个200,以此类推,最后是一个2*10e(n-1)。注意事项:注意最开始i的取值参考代码:#include<stdio.h>#include<……

[编程入门]Sn的公式求和

摘要:解题思路:注意事项:参考代码:#include<stdio.h>int main(){    int n,Sn = 0,i,a = 0;    scanf("%d",&n);    for(i=0; ……

水仙数求和

摘要:解题思路:注意事项:参考代码:for i in range(100,1000):    sn = 0    for j in str(i):        j=int(j)        sn += ……