• <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麻豆小说| 日本久久久久亚洲中字幕| 久久久无码人妻精品无码| 欧美激情精品久久久久| 久久久久国产| 亚洲色大成网站WWW久久九九| 欧美喷潮久久久XXXXx| 91久久九九无码成人网站| 伊人色综合久久天天网| 精品久久久久久久无码| 大香伊人久久精品一区二区 | 国产精品久久久久影视不卡| 久久久综合香蕉尹人综合网| 久久久久亚洲av成人网人人软件 | 欧美亚洲日本久久精品| 嫩草伊人久久精品少妇AV| 久久久久亚洲AV成人网| 99麻豆久久久国产精品免费| 伊人久久大香线焦AV综合影院 | 久久人人爽人人爽人人爽| 亚洲国产成人久久精品动漫| 日本欧美久久久久免费播放网| 欧美与黑人午夜性猛交久久久| 精品精品国产自在久久高清| 久久亚洲美女精品国产精品| 久久精品卫校国产小美女| 综合久久精品色| 久久这里只有精品首页| 亚洲一级Av无码毛片久久精品| 99久久久久| 94久久国产乱子伦精品免费| 狠狠色丁香婷综合久久| 99久久777色| 久久国产精品-久久精品| 久久免费线看线看| 国产香蕉97碰碰久久人人| 久久久艹| 国产成人精品久久| 色婷婷久久综合中文久久蜜桃av|