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

            <2010年6月>
            303112345
            6789101112
            13141516171819
            20212223242526
            27282930123
            45678910

            導航

            統計

            常用鏈接

            留言簿(2)

            隨筆分類(65)

            隨筆檔案(65)

            文章檔案(2)

            ACM

            搜索

            積分與排名

            最新隨筆

            最新評論

            閱讀排行榜

            亚洲狠狠综合久久| 嫩草影院久久99| 久久精品极品盛宴观看| 久久婷婷国产剧情内射白浆| 伊人久久大香线蕉综合网站| 无码人妻久久一区二区三区免费丨| 久久精品国产网红主播| 狠狠色综合网站久久久久久久| 久久精品免费全国观看国产| 麻豆精品久久精品色综合| 超级97碰碰碰碰久久久久最新| 色综合合久久天天综合绕视看| 波多野结衣AV无码久久一区| 精品视频久久久久| 国产成人精品久久一区二区三区 | 国产精品久久久久久久久久影院 | 日本精品一区二区久久久| 精品久久久久久成人AV| 中文字幕无码久久人妻| 99久久婷婷国产综合精品草原| 久久精品卫校国产小美女| 久久精品国产99久久久香蕉| 久久精品国产半推半就| 97久久国产综合精品女不卡 | 99精品久久久久久久婷婷| 性做久久久久久久久久久| 久久精品无码一区二区三区免费| 久久精品无码专区免费青青| 免费无码国产欧美久久18| 日本久久中文字幕| 午夜福利91久久福利| 久久久久国色AV免费看图片| 国产精品热久久无码av| 久久狠狠色狠狠色综合| 久久精品国产精品青草| 国产成人精品免费久久久久| 浪潮AV色综合久久天堂| 久久久久无码精品国产| 精品午夜久久福利大片| 国产成人精品久久一区二区三区av | 97久久综合精品久久久综合|