5-38 数列求和-加强版 (20分)

来源:互联网 发布:demo软件是什么意思 编辑:程序博客网 时间:2024/05/20 12:21


#include <iostream>#include <stdio.h>#include <algorithm>using namespace std;int a[10000020]= {0};int main(){    int A,N,b,i=0;    scanf("%d%d",&A,&N);    if(N==0) printf("%d",N);    else    {        int m=N;        for(i=0; m>0; i++)        {            a[i]+=m*A;            if(a[i]>9)            {                b=a[i]/10;                a[i]-=b*10;                a[i+1]=b;            }            m--;        }        i--;        if(a[i+1]>0)        {            i++;        }        for(int j=i; j>=0; j--)        {            printf("%d",a[j]);        }    }    return 0;}


1 0
原创粉丝点击