ural 1047 Simple Calculations

    技术2024-11-10  26

    将方程略加转换得到 (ai+1-ai)=(ai-ai-1)+2*ci

    便很好解了.

    #include<iostream> using namespace std; double sum,c,temp; double aN,a0; int n; int main() { int i,j,k; scanf("%d",&n); scanf("%lf%lf",&a0,&aN); for(i=0;i<n;i++) { scanf("%lf",&temp); c+=temp; sum+=c; } sum*=2; printf("%.2lf/n",(double)(aN+n*a0-sum)/(n+1)); return 0; }

    最新回复(0)