• <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 田兵 閱讀(343) 評論(0)  編輯 收藏 引用 所屬分類: URAL

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

            導航

            統計

            常用鏈接

            留言簿(2)

            隨筆分類(65)

            隨筆檔案(65)

            文章檔案(2)

            ACM

            搜索

            積分與排名

            最新隨筆

            最新評論

            閱讀排行榜

            久久99精品久久久久久| 亚洲精品国产第一综合99久久| 丰满少妇人妻久久久久久| 国产亚洲婷婷香蕉久久精品| 狠狠色综合久久久久尤物| 亚洲精品美女久久久久99| 青青青国产精品国产精品久久久久 | 热综合一本伊人久久精品| 久久婷婷五月综合97色一本一本| 99久久精品国产免看国产一区| 理论片午午伦夜理片久久 | 亚洲Av无码国产情品久久| 99久久国语露脸精品国产| 老男人久久青草av高清| 一本久久久久久久| 久久国产色AV免费观看| 久久久久亚洲AV无码专区首JN | 久久精品免费全国观看国产| 亚洲国产成人久久综合碰碰动漫3d | 久久99久久99精品免视看动漫| 亚洲日本久久久午夜精品| 国产精品免费久久| 国产欧美久久一区二区| 99久久久精品免费观看国产| 久久婷婷五月综合成人D啪| 色8激情欧美成人久久综合电| 婷婷综合久久中文字幕| 热久久这里只有精品| 国产精品岛国久久久久| 久久精品国产只有精品2020 | 色诱久久av| 2021最新久久久视精品爱| 99蜜桃臀久久久欧美精品网站| 波多野结衣久久| 亚洲日韩中文无码久久| 99久久无色码中文字幕人妻| 欧美精品久久久久久久自慰| 久久久久亚洲av无码专区喷水| 久久青青草原亚洲av无码app| 97精品久久天干天天天按摩| 88久久精品无码一区二区毛片 |