PersonalCorpus 版 (精华区)

148412 13:29:30
28 Feb 2002 Bozhang,HIT,P.R.China 1117 Pascal Accepted 0.22 sec 53K


const sp:array[1..1072] of integer=(
    1999999,1999995,2000004,2000000,1999995,1999997,
    2000007,2000003,1999997,1999995,2000000,2000002,
    1999995,2000005,2000002,2000002,2000001,1999995,
    2000002,2000000,1999995,1999995,2000005,1999999,
    2000003,1999993,2000002,2000008,1999997,2000001,
    2000001,1999995,2000007,1999999,2000002,1999998,
    1999997,1999999,2000003,1999999,2000001,2000007,
    1999988,2000002,1999993,2000007,1999998,1999998,
    2000001,2000007,1999996,2000000,1999993,2000003,
    1999999,2000009,1999999,2000003,1999994,2000002,
    1999999,1999999,2000002,1999992,2000003,1999995,
    2000012,1999996,2000003,1999991,2000011,1999997,
    2000001,1999999,1999998,1999998,2000001,1999999,
    2000004,1999994,2000005,1999995,2000006,1999996,
    2000011,1999989,1999999,2000009,1999993,2000001,
    1999992,2000012,1999995,1999999,1999999,2000007,
    1999991,1999999,2000002,2000010,1999997,1999995,
    2000001,2000007,1999993,2000005,1999988,2000002,
    2000001,1999999,2000000,2000002,2000007,1999995,
    2000004,1999994,2000009,1999989,2000005,2000003,
    1999999,1999997,2000002,1999996,2000003,1999995,
    2000007,2000001,1999991,1999999,2000004,1999996,
    1999999,2000005,2000007,2000001,1999995,2000003,
    2000000,1999994,1999997,2000015,1999996,2000002,
    1999995,2000003,1999998,1999998,2000001,2000007,
    1999991,2000003,1999995,2000001,2000000,2000002,
    1999997,2000001,2000003,2000001,1999993,1999999,
    2000006,1999996,1999999,1999999,2000007,2000001,
    1999995,2000009,2000002,1999990,1999999,2000001,
    1999998,2000004,2000005,1999993,2000000,1999998,
    2000003,1999997,1999995,2000013,1999999,1999997,
    1999998,2000000,1999999,1999999,2000000,2000006,
    2000001,1999987,2000004,1999994,2000005,1999995,
    2000007,2000003,2000007,1999999,1999998,2000002,
    1999993,2000003,1999998,2000002,2000005,1999993,
    2000000,2000000,2000005,1999997,1999991,2000007,
    1999995,2000005,1999996,2000008,1999991,2000003,
    1999997,2000005,1999997,1999997,2000010,1999998,
    1999997,1999999,2000005,1999997,1999997,2000009,
    2000000,2000000,1999989,1999999,2000006,1999996,
    2000007,1999991,2000008,1999996,2000001,1999995,
    2000007,1999997,1999999,1999995,2000008,2000000,
    1999995,1999997,2000010,2000002,1999999,1999999,
    1999992,2000004,1999995,2000001,2000003,2000001,
    1999995,2000005,1999994,2000016,1999989,2000009,
    1999998,2000002,1999999,2000001,1999994,2000004,
    1999999,2000001,1999999,1999995,1999999,2000001,
    1999996,2000008,2000007,1999993,2000003,1999997,
    2000005,1999995,2000000,1999996,2000007,1999993,
    2000005,1999995,2000003,2000003,1999998,1999998,
    2000009,1999991,2000000,1999998,2000005,1999999,
    1999996,1999998,2000003,1999999,2000001,2000013,
    1999989,2000003,1999994,2000006,1999995,2000003,
    2000000,2000006,1999995,2000001,1999992,2000000,
    1999999,1999995,2000011,2000003,1999993,2000001,
    1999998,2000002,1999997,1999997,2000010,2000002,
    1999999,1999997,1999998,2000000,2000009,1999993,
    2000009,2000001,1999989,1999999,2000000,2000004,
    1999997,1999995,2000003,2000007,1999997,1999997,
    2000008,1999994,1999999,1999995,2000005,2000005,
    1999993,2000003,2000000,2000000,1999997,1999991,
    2000004,1999998,2000015,1999999,2000000,1999994,
    2000003,1999999,1999999,2000005,1999995,2000001,
    1999998,2000000,1999999,2000001,1999999,2000003,
    2000003,1999999,2000002,1999990,1999997,2000003,
    2000001,2000003,1999991,2000009,1999996,2000000,
    1999995,2000013,1999994,2000000,2000003,2000007,2000000,1999994,
    2000005,1999999,1999999,2000003,1999999,1999989,2000004,2000002,
    2000001,1999997,2000001,1999999,2000003,1999993,2000012,1999990,
    2000003,1999995,2000005,1999999,2000001,2000003,2000002,2000002,
    1999995,2000001,1999990,2000006,2000001,1999997,1999998,2000010,
    1999995,1999999,1999997,2000013,1999995,1999995,1999996,2000010,
    1999993,2000001,1999996,2000008,1999997,1999997,2000000,2000008,
    1999989,1999997,2000013,1999997,2000001,1999995,2000002,1999998,
    2000001,2000001,2000004,1999992,2000005,1999993,2000004,1999996,
    2000013,1999995,2000005,1999999,2000001,1999989,2000000,2000004,
    1999995,2000003,2000003,1999997,1999999,1999997,2000010,2000000,
    1999991,2000007,2000001,2000001,1999995,2000009,1999992,2000002,
    1999993,2000009,1999998,1999992,2000005,1999999,2000000,1999998,
    1999997,1999999,2000009,2000003,1999997,2000001,1999994,2000002,
    1999995,2000001,2000009,1999999,2000003,1999995,2000004,1999996,
    2000003,1999987,2000005,2000005,1999999,2000001,1999994,2000002,
    1999999,2000003,2000000,1999998,2000003,1999997,1999998,2000000,
    2000005,1999993,2000001,2000017,1999999,1999999,1999990,2000010,
    1999999,1999997,2000001,2000003,1999999,1999997,2000002,2000000,
    2000001,1999991,2000003,2000003,2000001,2000005,1999994,2000002,
    1999999,1999999,2000000,2000002,1999993,2000003,1999996,2000002,
    1999999,1999997,1999999,2000013,1999995,2000007,2000000,1999996,
    1999997,1999999,2000004,2000002,1999995,2000001,2000004,1999996,
    1999999,1999987,2000013,1999999,1999997,1999999,2000008,1999994,
    1999999,1999999,2000006,1999998,1999997,1999995,2000008,1999994,
    2000009,1999999,1999999,2000003,1999995,2000001,2000008,1999996,
    1999995,2000003,1999997,2000005,1999993,2000001,2000004,2000002,
    1999997,2000001,1999995,2000005,1999993,2000007,1999996,2000004,
    1999995,2000005,1999996,2000004,2000009,1999987,2000002,1999994,
    2000009,1999995,1999999,2000003,2000003,1999995,2000000,1999994,
    2000009,1999997,2000003,2000001,2000005,1999991,2000004,1999994,
    2000007,1999995,1999997,2000001,1999999,2000001,1999998,1999996,
    1999999,2000015,1999996,2000004,1999999,1999995,1999998,2000002,
    1999999,2000003,1999995,2000007,1999995,2000001,1999996,2000010,
    1999987,1999999,2000011,2000003,1999999,1999993,2000006,2000000,
    1999997,1999997,2000001,2000003,1999997,2000005,2000004,1999998,
    1999995,1999999,2000010,1999996,2000005,1999987,2000002,2000000,
    1999999,1999997,2000003,2000007,1999997,1999997,2000000,2000004,
    1999991,1999999,2000004,2000008,1999999,1999993,2000004,2000000,
    1999997,1999997,2000011,1999993,2000001,2000003,1999996,2000000,
    1999995,2000005,2000000,1999998,2000007,1999999,1999994,1999998,
    2000005,1999999,2000001,1999999,2000001,2000001,1999996,2000004,
    1999987,2000005,1999999,2000001,1999997,2000011,2000004,1999998,
    2000001,1999997,2000003,1999995,1999999,2000007,1999996,2000000,
    1999999,1999999,2000000,1999998,2000007,2000003,1999992,1999996,
    2000005,1999993,2000005,1999999,2000001,1999997,2000002,2000000,
    2000001,1999991,2000008,2000006,1999997,1999997,2000006,2000000,
    1999999,1999995,2000007,2000003,1999987,2000003,1999994,2000008,
    1999995,2000003,1999998,2000006,1999997,1999999,1999992,2000008,
    2000001,1999997,1999999,2000009,1999991,2000001,1999994,2000016,
    1999997,1999989,2000005,1999999,2000001,1999995,2000008,1999992,
    2000015,1999993,2000007,1999999,1999995,2000003,2000002,1999996,
    2000003,1999995,2000004,1999998,2000005,1999995,2000004,1999988,
    2000001,2000001,2000003,2000011,1999991,2000005,1999996,2000002,
    1999995,2000007,1999994,2000004,1999995,2000003,2000000,1999996,
    1999997,2000009,2000003,2000003,1999987,2000003,2000000,1999998,
    1999997,2000005,2000000,2000000,1999999,1999999,2000002,1999992,
    2000011,1999995,2000007,2000001,2000001,1999993,2000002,2000000,
    2000001,1999997,1999993,2000005,2000001,1999995,2000006,1999996,
    2000001,1999997,2000001,2000011,1999999,1999997,1999998,2000000,
    1999999,2000001,1999996,2000004,2000009,1999997,1999998,2000004,
    1999991,1999997,1999999,2000007,2000003,1999995,1999998,2000004,
    1999997,1999999,1999997,2000005,2000003,1999995,2000002,2000000,
    1999997,1999997,2000003,2000003,2000005,1999993,1999996,2000004,
    1999993,2000011,2000002,1999996,2000001,1999999,2000002,1999998,
    1999997,1999999,2000003,2000001,1999997,2000001,2000000,2000006,
    1999995,2000001,2000003,1999991,2000001,1999993,2000012,1999996,
    1999997,1999995,2000009,1999997,1999999,2000009,2000004,2000000,
    1999995,2000003,2000002,1999996,2000003,1999999,2000002,1999998,
    1999991,2000001,1999999,2000009,1999995,2000003,1999992,2000010,
    1999993,2000003,2000000,2000000,1999997,2000001,1999998,2000004,
    1999993,2000001,2000009,2000001,1999999,2000001,1999990,1999998,
    2000009,1999999,2000002,1999994,2000007,1999995,2000000,1999996,
    2000013,1999989,2000003,1999999,2000003,1999997,1999996,2000002,
    2000007,1999995,2000003,1999991,2000001,1999999,2000006,2000002,
    1999997,1999999,2000001,2000005,1999993,2000007,1999990,2000004,
    1999995,2000011,1999998,2000004,1999999,2000001,1999996,2000002,
    1999999,1999989,2000005,2000007,1999995,1999999,1999996,2000004,
    1999997,1999997,2000012,2000004,1999995,1999995,2000008,1999994,
    2000001,1999991,2000013,1999999,1999997,1999999,2000004,1999990,
    1999997,2000003,2000002,2000008,1999997,1999997,2000002,1999998,
    2000003,1999991,2000003,2000007,1999995,1999999,2000000,2000008,
    1999995,2000003,1999997,2000009,1999989,1999999,2000004,1999996,
    2000001,1999999,1999999,2000001,1999999,2000007,1999998,1999994,
    1999999,2000003,1999998,2000000);
var
    res,m,n,i:integer;
function CalcLevel(a:integer):integer;
begin
    result:=0; while a mod 2 =0 do begin inc(result); a:=a div 2 end;
end;
function Running(s,t:integer):integer;
var
    i,j,k:integer;
begin
    result:=0;
    j:=CalcLevel(s);
    for i:=s to t-1 do begin
        k:=CalcLevel(i+1);
        result:=result+abs(j-k)-1;
        j:=k;
    end;
end;
begin
    readln(m,n);
    if m>n then begin i:=m; m:=n; n:=i end;
    res:=0;
    if n-m>=2000000 then begin
        if m mod 2000000=0 then i:=m else i:=2000000+m-(m mod 2000000);
        res:=res+Running(m,i);
        while n-i>=2000000 do begin
            res:=res+sp[i div 2000000];
            i:=i+2000000;
        end;
        if i<>n then res:=res+Running(i,n);
    end else res:=Running(m,n);
    writeln(res);
end.
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:4.204毫秒