提交时间:2023-10-11 14:06:31

运行 ID: 106422

#include<bits/stdc++.h> using namespace std; string adds(string s1,string s2)//高精度函数 { int lena=s1.length(),lenb=s2.length(),a[1145]={},b[1145]={},c[1145]={},lenc=1,x=0,i; string answer; for(i=0;i<=lena-1;i++) a[lena-i]=s1[i]-'0'; for(i=0;i<=lenb-1;i++) b[lenb-i]=s2[i]-'0'; while(lenc<=lena||lenc<=lenb) { c[lenc]=a[lenc]+b[lenc]+x; x=c[lenc]/10000; c[lenc]%=10000; lenc++; }c[lenc]=x; if(c[lenc]==0){lenc--;} for(i=lenc;i>=1;i--){answer+=c[i]+'0';} return answer; } struct number {string a;}num[114514]; string ans; int n; int main() { cin>>n; for(long long i=0;i<n;i++) {cin>>num[i].a;} for(long long i=0;i<n;i++) {ans=adds(ans,adds(num[i].a, { for(long long j=i+1;j<n;j++)num[j].a));} } cout<<ans; return 0; }