PAT (Advanced Level) 1104. Sum of Number Segments (20)

Posted Fighting Heart

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PAT (Advanced Level) 1104. Sum of Number Segments (20)相关的知识,希望对你有一定的参考价值。

简单题。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;

int n;
double a[100000+10];
double b[100000+10];
double sum=0;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) b[i]=1.0*(n-i+1)*i;
    for(int i=1;i<=n;i++) scanf("%lf",&a[i]);
    for(int i=1;i<=n;i++) sum=sum+b[i]*a[i];
    printf("%.2lf\n",sum);
    return 0;
}

 

以上是关于PAT (Advanced Level) 1104. Sum of Number Segments (20)的主要内容,如果未能解决你的问题,请参考以下文章

1104. Sum of Number Segments (20)数学题——PAT (Advanced Level) Practise

1104. Sum of Number Segments (20)数学题——PAT (Advanced Level) Practise

PAT (Advanced Level) 1025. PAT Ranking (25)

PAT Advanced Level 1044

PAT Advanced Level 1043

PAT Advanced Level 1079