Click here to load reader

Analysis day2

  • View
    575

  • Download
    0

Embed Size (px)

Text of Analysis day2

  • , II

    . .

    . .

    ,

    2016 .

    1/36 , II

  • ,

    a, b c n/3.

    2/36 , II

  • .

    :

    a < b , a+ b = m.

    a2 + b2 , b a 2.

    3/36 , II

  • .

    a b: b a > 2. a+ 1 6= b 1 (a+ 1)2 + (b 1)2 = a2 + 2a+ 1 + b2 2b+ 1 =a2 + b2 + 2(a b) + 2 < a2 + b2 4 + 2 < a2 + b2 a b a+ 1 b 1, , a b , a+ 1 6= b 1 , b a 2.

    4/36 , II

  • .

    a, b c, .

    a b c, b c a, 2

    n/3:{

    b a 2

    c b 2 c a 4 a, b, c [n/3 2, n/3 + 2]

    5/36 , II

  • ,

    , 2 n/3, .

    6/36 , II

  • , ,

    .

    1

    (n 3) | 3, a, a+ 1, a+ 2, a = (n 3)/3.

    2

    (n 5) | 3, a, a+ 2, a+ 3, a = (n 5)/3.

    3

    a, a+ 1, a+ 3, a = (n 4)/3.

    .

    7/36 , II

  • ?

    8/36 , II

  • 1

    x .

    2

    ount, ount[i

    i.

    3

    C all rep, :

    1

    all ;

    2

    rep , (

    rep ).

    9/36 , II

  • ount

    .

    a.

    ount[a 3, 1.

    10/36 , II

  • ount

    .

    a.

    ount[a 2, a

    (a, a k]:1

    all

    .

    2

    3, x 3 : a, a, x, a, x, a, x, a, a.

    10/36 , II

  • ount

    .

    a.

    a :

    1: .

    1

    rep

    (a, a k].2

    3, 3 : a, x, x,x, x, a, x, a, x.

    2: .

    1

    all .

    2

    Cn2 , 3

    .

    10/36 , II

  • ,

    O(N), O(N logN), .

    11/36 , II

  • .

    .

    12/36 , II

  • ?

    13/36 , II

  • 1:

    L R ,

    .

    2

    ,

    .

    ,

    .

    1 1018 4 686 824 , .

    14/36 , II

  • 1

    c(L,R) L R.

    2

    , c(L,R) = c(1, R) c(1, L 1) c, 1.

    3

    c .

    15/36 , II

  • 3 , R = 10k

    10k , ,

    k , ( 0, 1).

    16/36 , II

  • 3 , R = 10k

    d[i][j] i , j.

    d[i][j] =

    {

    d[1][j] = 1 j

    d[i][j] = sum(d[i 1][k], k = 0 . . . j) i > 1

    109 + 7.

    1

    i = 3, j = 5.

    2

    ab5.

    3

    ab

    , 0, 1, 2, 3, 4, 5

    .

    17/36 , II

  • (

    ).

    1

    R , < R.

    2

    R i, R[i] > R[i+ 1].

    3

    R[i] 1, .

    4

    R[i] 1,

    , .

    18/36 , II

  • R = 24415

    1

    , 1 > 4 : R = 24399.

    2

    3 > 4 : R = 23999.

    3

    R.

    19/36 , II

  • R 10, .

    ,

    R, .

    T 134.T = 134xxxxxR = 13677899 4 < 6, x 4, . T 135.T = 135xxxxxR = 13588899 5 = 5, R.

    20/36 , II

  • 1

    R. k.

    2

    k :

    1

    d[i][j] i , j.

    2

    : k R, .

    3

    ,

    :

    d[k + 1][j] = 1 j, k R (k + 1)- .

    21/36 , II

  • k = 3.T=135xxxxxR=13588899 x 6 7,

    d[3][6] = 1, d[3][7] = 1.: , x 8,

    k = 4.

    22/36 , II

  • ?

    23/36 , II

  • x y . :

    x, y, (y x),x,y, (x y), x, y, . . . 6.

    :

    |x b1|+ |y b2|+ |(y x) b3|+ | x b4|+ | y b5|+|(x y) b6|+ . . . :

    |x b1|+ |y b2|+ |(y x) b3|+ |x (b4)|+|y (b5)|+ |(y x) (b6)|+ . . .

    24/36 , II

  • |x b1|+ |y b2|+ |(y x) b3|+ |x (b4)|+ |y (b5)|+|(y x) (b6)|+ . . .

    1

    :

    1

    |x a|;2

    |y b];3

    |(y x) c|

    2

    bx, by byx

    ,

    .

    25/36 , II

  • , x, y, .

    , , :

    1

    x.

    2

    ,

    |y b|.

    3

    b:|y b1|+ |y b2|+ |y b3|+ . . ., b1 b2 b3 . . ..

    26/36 , II

  • y 1?: |y 3|+ |y 5|+ |y 8|

    27/36 , II

  • 1

    nLeft y, nRight y.

    2 f(x, y + 1) f(x, y) = nLeft nRight.

    3

    y nLeft < nRight, nLeft > nRight , .

    4

    y .

    28/36 , II

  • -

    .

    :

    ;

    ;

    100 .

    29/36 , II

  • :

    f(x) [l, r] , .

    :

    1

    a = l + (r l)/3, b = r (r l)/3.

    2

    f(a) < f(b), [l, b], [a, r].

    3

    C .

    30/36 , II

  • .

    x . x , y .

    : 2 109 2 109.

    31/36 , II

  • f (x, y)

    .

    v

    :

    pref[i = v[0 + v[1 + . . . + v[i .

    , :

    suf[i = v[i + v[i + 1 + . . . + v[n.

    32/36 , II

  • f (x, y)

    ,

    bx pos, < x, x.

    Sum = x pospref[pos - 1 +suf[posx (bx.size() pos).

    : x, x.

    .

    33/36 , II

  • ,

    :

    (x, y), ,,

    .

    O(n3):

    1

    .

    2

    , ,

    x y, , .

    O(n2 log n):

    1

    , ,

    , x y.

    2

    C

    .

    34/36 , II

  • ?

    35/36 , II

  • !

    36/36 , II