• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Ural 1047 Simple calculations

            1047. Simple calculations

            Time Limit: 1.0 second
            Memory Limit: 16 MB
            There is a sequence of N + 2 elements a0, a1, …, aN+1 (1 ≤ N ≤ 3000, −2000 ≤ ai ≤ 2000). It is known that
            ai = (ai−1 + ai+1)/2 − ci
            for each i = 1, 2, …, N.
            You are given a0, aN+1, c1, …, cN. Write a program which calculates a1.

            Input

            The first line contains an integer N. The next two lines consist of numbers a0 and aN+1 each having two digits after decimal point, and the next N lines contain numbers ci (also with two digits after decimal point), one number per line.

            Output

            Output a1 in the same format as a0 and aN+1.

            Sample

            input output
            1
                                    50.50
                                    25.50
                                    10.15
                                    
            27.85
                                    
            Problem Author: Dmitry Filimonenkov
            Problem Source: Ural State University collegiate programming contest (25.03.2000)

               用數學方法推出公式即可:
                 
             
            //ural1047
            //a1=( aN_1 +N*a0 -2*( (c1+……cN)+ (c1+……cN-1 ) +……(c1+c2)+(c1) ))/(N+1)
            #include<iostream>
            using namespace std;
            double ci[3010]={0};  //ci[i]=c1+c2+……ci
            int main()
            {
               
            int N,i;
               
            double a0,aN_1,temp,sum=0;
               cin
            >>N>>a0>>aN_1;
               
            for(i=1; i<=N; i++)
               {
                   cin
            >>temp; 
                   ci[i]
            =ci[i-1]+temp;
                   sum
            +=ci[i];
               }

               sum
            *=2;

               cout.precision(
            2);
               cout
            <<fixed<<( aN_1+ N*a0 -sum)/(N+1)<<endl;

               system(
            "pause");
                
            return 0;
            }

            posted on 2010-06-24 23:09 田兵 閱讀(332) 評論(0)  編輯 收藏 引用 所屬分類: URAL

            <2010年8月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            2930311234

            導航

            統計

            常用鏈接

            留言簿(2)

            隨筆分類(65)

            隨筆檔案(65)

            文章檔案(2)

            ACM

            搜索

            積分與排名

            最新隨筆

            最新評論

            閱讀排行榜

            久久天天躁狠狠躁夜夜网站| 久久综合丝袜日本网| 精品久久久久久无码不卡| 一本综合久久国产二区| 久久99精品国产一区二区三区 | 色婷婷久久综合中文久久蜜桃av| 久久狠狠色狠狠色综合| 亚洲国产视频久久| 久久影视综合亚洲| 久久亚洲熟女cc98cm| 欧美日韩成人精品久久久免费看| 人妻无码中文久久久久专区| 亚洲国产一成人久久精品| 国内高清久久久久久| 久久强奷乱码老熟女网站| 久久天天躁夜夜躁狠狠| 无码人妻久久久一区二区三区| 久久亚洲国产精品成人AV秋霞| 亚洲中文字幕无码久久2020| 波多野结衣AV无码久久一区| 久久亚洲国产成人精品性色| 久久精品国内一区二区三区| 久久伊人色| 麻豆精品久久精品色综合| 久久婷婷午色综合夜啪| 精品久久8x国产免费观看| 久久这里有精品视频| 九九精品99久久久香蕉| 国内精品久久久久久久影视麻豆| 色天使久久综合网天天| 999久久久国产精品| 久久人人爽人人爽人人AV东京热| 久久精品视屏| 国内精品久久久久久久涩爱| 久久Av无码精品人妻系列| 色悠久久久久久久综合网| 狠狠色丁香婷婷久久综合五月 | 日本久久久精品中文字幕| 久久成人国产精品免费软件| 国内精品久久久久影院老司| 久久九九久精品国产|