• <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)

               用數(shù)學方法推出公式即可:
                 
             
            //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 田兵 閱讀(334) 評論(0)  編輯 收藏 引用 所屬分類: URAL

            <2010年12月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            導航

            統(tǒng)計

            常用鏈接

            留言簿(2)

            隨筆分類(65)

            隨筆檔案(65)

            文章檔案(2)

            ACM

            搜索

            積分與排名

            最新隨筆

            最新評論

            閱讀排行榜

            色欲久久久天天天综合网| 精品久久久久中文字| 久久精品国产免费观看三人同眠| 久久午夜综合久久| 精品久久久无码人妻中文字幕豆芽| 久久精品中文字幕久久| 久久精品亚洲男人的天堂| 久久久久久久久久久精品尤物 | 久久久精品波多野结衣| 色婷婷噜噜久久国产精品12p| 久久精品九九亚洲精品| 精品久久久久久99人妻| 久久久无码一区二区三区| 理论片午午伦夜理片久久| 国产精品99久久99久久久| 久久久久亚洲AV片无码下载蜜桃 | 色8激情欧美成人久久综合电| 久久久无码精品亚洲日韩按摩| 久久亚洲精品无码播放| 波多野结衣中文字幕久久| 99蜜桃臀久久久欧美精品网站| 久久精品?ⅴ无码中文字幕| 久久99精品综合国产首页| 午夜精品久久久久久毛片| 一本大道久久香蕉成人网| 久久久精品人妻无码专区不卡| 99国产欧美久久久精品蜜芽| 少妇人妻88久久中文字幕| 丁香色欲久久久久久综合网| 精品国产乱码久久久久软件| 久久国产精品免费| 久久久久九国产精品| 亚洲国产天堂久久综合| 日韩欧美亚洲综合久久影院Ds| 久久综合色之久久综合| 亚洲国产成人久久综合一区77| 久久99精品国产麻豆蜜芽| 色偷偷91久久综合噜噜噜噜| 怡红院日本一道日本久久 | 久久精品国产亚洲AV无码娇色| 精品熟女少妇AV免费久久|