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

            coreBugZJ

            此 blog 已棄。

            reverse order 2,HUST Monthly 2011.04.09 之 D,1434

            reverse order 2

            Time Limit: 1 Sec Memory Limit: 128 MB
            Submissions: 157 Solved: 64

            Description

            Here is a sequence a1..n, which is a disordered sequence from 1 to N. if i < j and ai > aj, <i, j> is called a pair of inversion. And b1..n-1 is defined as follows, bk is the number of the total inversion pairs in array a, when i<=k<j. Now the array a is required while the array b is known.

             

            Input

             

            Several cases end with the end of the file;

            And each of the cases includes two lines, a integer n(2<=n<=10^5)in the first line, and the second line followed with n-1 integer, which is in the presentation of array b;

             

            Output

            Output the answer of each case in a line, namely the array a, and a space is required between adjacent integers.

             

            Sample Input

            5
            2 1 2 0

            Sample Output

            3 1 4 2 5
             
            a[ 1 ] = b[ 1 ] + 1;
            求 b[ i ] 時,a[ i ] 左邊比它大的有 X 個,a[ i ] 右邊比它小的有 Y 個,
            則比 a[ i ] 小的一共有 ( Y - X + i - 1 ) 個,所以 a[ i ] = Y - X + i,
            即 a[ i ] = b[ i ] - b[ i - 1 ] + i。
             
            用 int 的 b 會錯誤,要 long long 的 b 。
             
             
             1/*
             2// int b, WA
             3#include <stdio.h>
             4#include <string.h>
             5
             6#define  L  100009
             7
             8int has[ L ];
             9
            10int main() {
            11        int n, i, a, b, bk;
            12        while ( scanf( "%d", &n ) == 1 ) {
            13                memset( has, 0, sizeof(has) );
            14                bk = 0;
            15                for ( i = 1; i < n; ++i ) {
            16                        scanf( "%d", &b );
            17                        a  = b - bk + i;
            18                        bk = b;
            19                        has[ a ] = 1;
            20                        printf( "%d ", a );
            21                }
            22                for ( i = 1; i <= n; ++i ) {
            23                        if( has[ i ] == 0 ) {
            24                                a = i;
            25                        }
            26                }
            27                printf( "%d\n", a );
            28        }
            29        return 0;
            30}
            31*/

            32
            33
            34// long long b, AC
            35#include <stdio.h>
            36#include <string.h>
            37
            38#define  L  100009
            39
            40int has[ L ];
            41
            42int main() {
            43        int n, i, a;
            44        long long bk, b;
            45        while ( scanf( "%d"&n ) == 1 ) {
            46                memset( has, 0sizeof(has) );
            47                bk = 0;
            48                for ( i = 1; i < n; ++i ) {
            49                        scanf( "%lld"&b );
            50                        a  = b - bk + i;
            51                        bk = b;
            52                        has[ a ] = 1;
            53                        printf( "%d ", a );
            54                }

            55                for ( i = 1; i <= n; ++i ) {
            56                        if( has[ i ] == 0 ) {
            57                                a = i;
            58                        }

            59                }

            60                printf( "%d\n", a );
            61        }

            62        return 0;
            63}

            64

            posted on 2011-04-10 22:57 coreBugZJ 閱讀(3537) 評論(0)  編輯 收藏 引用 所屬分類: ACM

            精品国产乱码久久久久久1区2区| 99热成人精品免费久久| 久久99九九国产免费看小说| 日韩精品无码久久一区二区三| 18禁黄久久久AAA片| 久久Av无码精品人妻系列| 久久99国产亚洲高清观看首页| 久久se精品一区二区影院| 日本五月天婷久久网站| 国内精品久久国产大陆| 久久国产欧美日韩精品免费| 人妻精品久久无码区| 国产精品免费久久久久电影网| 久久亚洲国产成人影院| 91精品国产综合久久香蕉 | 少妇久久久久久被弄到高潮| 久久亚洲精品中文字幕| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 精品国产乱码久久久久久呢 | 婷婷久久综合九色综合绿巨人| 蜜臀av性久久久久蜜臀aⅴ| 久久久久国色AV免费观看| 丰满少妇高潮惨叫久久久| 久久人人爽人人爽人人片AV不 | 国产精品亚洲美女久久久| 色婷婷综合久久久久中文一区二区| 丁香五月综合久久激情| 久久人人爽人人人人爽AV| 久久精品国产一区二区三区不卡| 久久青青草原精品国产| 久久精品国产日本波多野结衣| 国产精品伦理久久久久久| 久久久国产精品网站| 国产精品对白刺激久久久| 狠狠色婷婷久久一区二区三区| 久久婷婷五月综合成人D啪| 久久笫一福利免费导航| 国产精品久久久久a影院| 一本色综合久久| 狠狠色丁香久久婷婷综合蜜芽五月| 日韩亚洲国产综合久久久|