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

            搜索

            積分與排名

            最新隨筆

            最新評論

            閱讀排行榜

            国产叼嘿久久精品久久| 久久精品国产亚洲av影院| 久久人妻少妇嫩草AV蜜桃| 婷婷久久综合九色综合绿巨人| 久久久久久久97| 91精品国产91热久久久久福利| 久久精品成人欧美大片| 日本三级久久网| 久久香蕉超碰97国产精品| 久久婷婷人人澡人人| 狠狠狠色丁香婷婷综合久久俺| 久久综合亚洲色HEZYO社区 | 久久无码中文字幕东京热| 久久国产精品成人免费| 亚洲AV无码久久精品狠狠爱浪潮| 国产免费久久久久久无码| 国产精品免费看久久久| 偷窥少妇久久久久久久久| 久久久久人妻一区精品| 青青青青久久精品国产h| 91精品国产高清久久久久久io | 少妇精品久久久一区二区三区| 久久五月精品中文字幕| 94久久国产乱子伦精品免费 | 久久99国产精品久久99| 亚洲av日韩精品久久久久久a | 久久人人爽人人爽人人片AV东京热| 久久99国产精品久久久| 欧美伊香蕉久久综合类网站| 久久精品草草草| 国产成人久久久精品二区三区| 青草影院天堂男人久久| 99久久精品免费观看国产| 国产精品九九久久免费视频| 久久99精品国产麻豆蜜芽| 99热成人精品免费久久| 久久精品国产72国产精福利| 四虎影视久久久免费观看| 久久久黄色大片| 久久精品人人做人人爽97| 亚洲精品国产成人99久久|