问题 3:Round Numbers(rndnum.pas)
正如你所知,奶牛们没有手指以至于不能玩“石头剪刀布”来任意地决定例如谁先挤奶的顺序。她们甚至也不能通过扔硬币的方式。
所以她们通过"round number"竞赛的方式。第一头牛选取一个整数,小于20亿。第二头牛也这样选取一个整数。如果这两个数都是 "roundnumbers",那么第一头牛获胜,否则第二头牛获胜。如果一个正整数N的二进制表示中,0的个数大于或等于1的个数,那么N就被称为"round number" 。例如,整数9,二进制表示是1001,1001 有两个'0'和两个'1'; 因此,9是一个roundnumber。26 的二进制表示是 11010 ; 由于它有2个'0'和3个'1',所以它不是round number。
很明显,奶牛们会花费很大精力去转换进制,从而确定谁是胜者。 Bessie 想要作弊,而且认为只要她能够知道在一个指定区间范围内的"round numbers"个数。
帮助她写一个程序,能够告诉她在一个闭区间中有多少round numbers。区间是[start, finish],包含这两个数。 (1 <= Start <Finish <= 2,000,000,000)
输入格式:
Line 1: 两个用空格分开的整数,分别表示Start 和 Finish。
输入样例 (文件名rndnum.in):
2 12
输出格式:
Line 1: Start..Finish范围内round numbers的个数
输出样例(文件名 rndnum.out):
6
输出解释:
2 10 1x0 + 1x1 ROUND
3 11 0x0 + 2x1 NOT round
4 100 2x0 + 1x1 ROUND
5 101 1x0 + 2x1 NOT round
6 110 1x0 + 2x1 NOT round
7 111 0x0 + 3x1 NOT round
8 1000 3x0 + 1x1 ROUND
9 1001 2x0 + 2x1 ROUND
10 1010 2x0 + 2x1 ROUND
11 1011 1x0 + 3x1 NOT round
12 1100 2x0 + 2x1 ROUND
部分打表,不说了。
#include <cstdio>
#include <iostream>
using std::cout;
long f[] = {0,226671,483212,737725,912008,1220551,1496047,1749378,1936710,2208053,2497049,2743397,2953836,3157573,3372377,3533445,3666046,3822350,4224609,4558029,4888435,5131434,5470687,5729104,5985204,6157619,6473508,6741419,6997710,7184512,7407121,7600515,7759888,7878985,8114246,8502313,8841202,9154535,9418915,9742350,9988999,10225651,10387703,10718919,10975302,11232599,11401951,11649467,11825190,11988312,12093372,12360457,12647109,12895092,13090291,13302778,13513784,13676013,13806423,13946699,14173972,14335036,14478373,14575034,14726176,14808964,14902859,14946704,15366960,15792716,16201541,16568569,16950748,17320882,17658367,17948041,18268984,18655708,18993614,19304776,19575038,19889061,20140363,20372618,20548986,20954246,21286246,21629379,21888932,22223809,22491383,22743425,22921271,23217773,23499961,23749996,23944182,24150382,24358905,24523611,24649517,24844562,25239333,25575788,25899457,26153139,26483106,26726212,26967731,27136639,27475420,27738160,27991458,28168391,28403584,28590392,28751667,28863469,29097194,29391262,29645428,29857766,30054847,30273534,30430558,30571623,30692950,30926915,31084403,31236620,31322215,31490033,31584664,31677365,31722784,32094335,32527953,32938298,33310112,33680631,34055961,34396663,34701584,35001221,35395499,35730307,36047985,36309807,36635786,36881147,37121164,37273072,37692107,38040900,38382504,38649432,38971194,39245514,39498926,39686790,39958625,40247627,40492390,40703186,40907482,41121804,41282752,41415809,41573188,41975390,42308110,42639015,42882438,43219905,43478493,43734948,43906876,44223844,44492036,44747692,44934441,45156905,45350847,45510155,45627800,45840354,46146335,46397270,46616525,46797246,47028856,47188149,47334412,47430638,47671874,47835026,48002942,48096930,48259763,48357468,48448125,48497734,48799637,49172421,49508491,49797582,50092717,50397838,50647285,50865457,51071367,51391483,51639722,51872548,52038237,52278629,52431729,52600543,52694622,53020857,53287273,53538205,53720987,53952633,54139486,54303343,54415411,54594406,54804200,54968337,55096784,55216155,55348037,55439122,55513038,55592659,55922617,56165030,56415984,56584461,56836115,57009738,57174501,57272938,57496304,57683649,57845934,57956895,58089661,58210498,58302816,58365000,58498196,58717626,58876476,59018091,59121009,59268870,59354387,59434896,59477906,59644792,59739331,59832161,59878002,59964450,60014029,60056665,60076643,60356503,60832929,61292355,61739336,62157785,62607725,63014730,63415911,63759376,64214443,64621615,65027775,65366317,65781109,66131483,66473788,66741671,67140388,67574495,67984879,68356227,68727353,69102878,69442860,69747432,70048316,70442235,70777285,71093426,71356714,71682210,71927618,72167098,72320180,72784249,73203960,73616038,73972480,74364372,74726814,75067396,75349646,75688080,76062801,76395436,76700591,76986376,77294730,77543388,77764296,77972001,78374089,78707107,79037922,79281610,79616994,79876058,80132387,80303811,80621812,80890614,81145062,81331785,81554249,81748724,81907967,82024534,82276494,82723402,83133241,83527480,83872636,84274697,84609414,84937177,85185284,85591583,85934320,86280095,86540180,86872870,87140810,87390835,87576880,87902849,88275274,88611237,88900647,89194906,89499996,89748790,89967525,90174431,90493471,90741709,90975179,91140854,91381110,91532545,91701463,91795449,92183365,92538756,92877836,93153714,93467319,93748313,93999860,94194786,94444353,94748270,94999986,95215060,95405882,95625823,95788119,95931200,96047470,96377786,96620172,96869154,97037422,97290160,97462900,97628044,97725833,97950183,98136940,98299146,98409864,98543891,98663526,98755904,98818321,99002551,99452764,99861258,100262374,100601883,101006822,101339583,101670764,101927767,102336625,102687164,103029697,103298467,103616490,103896024,104146672,104339030,104632412,105008548,105352101,105657336,105936318,106247857,106494260,106721667,106910321,107235112,107481791,107722186,107877826,108136055,108305861,108471855,108569162,108916931,109284495,109624072,109906642,110205797,110495619,110745479,110955508,111188441,111499976,111747692,111967859,112150656,112383147,112540704,112690189,112775562,113119063,113378644,113632180,113807425,114048160,114226550,114392411,114499096,114702040,114896543,115053406,115176571,115308109,115434116,115525006,115591397,115722990,116124761,116458302,116788495,117032797,117365986,117625403,117881775,118052825,118371701,118640976,118894208,119080868,119303270,119498192,119657664,119773328,119988254,120294996,120545046,120763905,120945045,121176200,121336136,121480775,121579976,121821271,121980720,122148660,122243240,122406112,122503832,122593572,122643346,122908349,123192968,123441282,123637597,123847200,124058196,124219125,124350577,124493965,124717984,124879234,125023916,125120763,125271719,125352629,125445070,125488847,125735864,125910474,126074460,126175283,126327601,126434106,126525027,126578569,126693526,126818609,126910251,126973480,127039825,127106914,127148003,127179226,127251621,127734914,128191237,128651662,129069646,129523981,129948078,130359704,130716856,131133859,131567968,131977434,132351151,132718117,133101205,133441887,133747588,134049617,134499795,134907729,135309239,135648920,136053658,136386413,136717787,136972604,137383022,137732340,138075964,138344004,138661971,138940902,139192507,139384120,139698502,140136340,140550955,140938928,141295356,141688413,142023212,142343653,142610073,143012434,143347116,143678155,143921714,144269096,144529531,144784195,144958446,145316040,145682372,146022471,146303963,146604705,146894024,147142583,147352288,147587117,147897332,148145663,148365060,148548773,148780949,148938390,149088187,149174785,149637233,150056636,150468875,150825115,151218295,151578168,151920391,152202071,152542103,152916389,153249958,153551930,153839891,154145817,154396693,154616399,154826045,155227242,155561520,155890809,156135944,156466934,156726671,156983222,157153836,157473887,157743400,157996022,158182273,158406211,158600224,158760175,158874166,159116878,159505703,159843317,160155837,160420538,160743561,160991142,161224385,161391777,161723171,161971486,162229079,162399241,162647554,162822781,162983701,163089413,163362582,163646773,163895312,164091959,164301008,164511654,164673492,164804119,164949123,165171416,165333752,165477730,165575125,165725315,165807371,165897984,165941752,166370077,166795508,167205852,167568625,167953647,168323010,168661112,168949978,169269285,169656972,169995863,170304315,170577198,170891824,171140558,171372508,171552827,171958811,172290912,172627010,172885964,173225676,173489360,173742691,173918835,174219096,174499941,174748911,174943215,175153498,175355166,175520375,175646659,175848779,176243029,176576311,176900711,177157138,177484893,177728357,177970032,178132120,178475224,178735159,178991373,179166692,179401406,179587389,179751401,179859857,180100759,180390074,180644644,180855620,181053852,181272406,181431769,181567873,181694035,181927278,182085383,182236559,182317175,182486081,182580079,182672700,182717832,183067098,183431847,183772636,184053531,184355413,184644428,184891885,185102035,185337922,185647873,185896202,186115962,186299105,186531185,186687866,186838183,186925879,187266365,187525008,187780616,187953552,188196309,188372112,188539203,188645018,188849867,189043115,189202193,189322055,189454431,189579841,189671509,189737468,189861802,190184986,190431655,190668658,190828287,191068871,191235561,191403242,191497541,191739834,191915885,192079385,192184556,192332108,192442023,192531455,192585245,192746827,192958205,193120445,193250701,193364715,193503241,193592858,193666748,193724442,193875750,193959598,194053386,194097328,194189008,194234263,194276770,194295171,194627222,195062975,195471713,195847123,196215551,196602612,196939986,197251886,197535093,197931143,198268868,198594147,198845245,199175452,199417121,199671155,199840082,200233258,200590088,200928959,201201582,201516896,201799399,202049470,202244159,202493170,202797347,203049631,203262572,203456097,203676563,203836359,203978505,204103784,204509505,204841808,205175731,205435086,205775376,206038437,206291735,206468489,206768780,207049490,207297793,207492573,207703379,207903679,208069057,208195582,208381790,208694983,208938856,209170457,209344894,209579704,209736557,209889101,209975420,210232336,210402035,210568468,210666237,210819262,210924875,211016504,211067401,211333193,211708324,212050049,212355104,212634241,212947136,213193724,213417773,213609560,213935434,214180858,214421225,214572610,214831734,215000695,215166326,215263672,215565753,215840847,216094199,216281696,216502504,216697404,216854711,216979760,217149788,217364481,217525464,217658271,217769659,217912560,217998091,218078215,218124678,218463169,218721488,218977770,219149987,219393469,219568942,219736043,219841818,220047268,220240823,220400161,220518682,220651480,220777322,220868323,220934231,221041028,221272227,221431580,221578365,221669626,221821770,221911696,222005307,222049086,222209933,222307783,222398422,222447923,222531972,222583492,222625439,222646189,222865780,223253767,223591447,223903156,224170069,224490757,224739027,224971616,225141273,225472338,225716606,225975427,226144886,226393993,226568495,226731471,226834562,227111453,227393286,227644014,227839376,228047200,228256982,228420724,228549355,228697320,228916573,229080486,229223598,229321990,229471646,229555458,229642847,229686560,230016667,230283785,230536044,230713391,230948410,231136126,231298361,231409589,231590491,231798385,231963310,232088898,232212253,232344198,232431710,232504947,232585590,232823567,232979157,233130585,233224571,233391123,233486140,233578689,233624745,233773602,233879142,233969467,234022282,234099217,234153992,234197500,234222780,234379966,234692541,234937247,235167206,235342843,235576519,235734487,235886423,235971490,236228638,236398705,236564803,236662516,236815352,236921063,237012684,237063472,237247497,237444293,237606795,237731831,237857993,237988991,238077788,238145042,238224378,238368587,238455291,238534842,238571998,238663080,238706847,238750094,238767287,238997267,239177109,239342331,239449160,239592705,239704796,239790269,239852430,239963551,240090751,240180370,240247537,240307056,240380948,240420588,240455165,240479774,240635356,240729221,240822587,240866819,240957180,241003049,241045988,241065003,241143803,241197146,241238442,241260376,241295027,241320504,241336697,241345324,241475587,241970378,242453834,242937055,243393509,243876850,244339749,244801587,245221407,245687144,246155922,246614919,247047795,247481407,247918179,248326558,248701453,249092491,249571816,250029465,250479070,250893029,251346239,251754610,252157134,252494185,252950418,253358511,253777255,254126550,254529543,254885092,255223516,255499961,255891646,256364830,256822800,257260638,257687849,258133066,258543447,258935641,259292758,259742975,260153288,260555574,260892697,261298095,261630169,261971087,262229941,262669402,263094738,263505636,263864491,264253044,264622065,264959725,265247356,265569388,265954225,266294691,266599821,266877076,267190269,267437360,267667909,267856020,268339267,268795669,269251902,269671160,270127276,270549462,270961742,271319814,271737096,272170758,272579664,272953780,273322128,273699485,274042310,274348058,274653636,275103447,275510591,275911425,276252915,276655624,276989958,277321102,277568085,277982408,278333035,278675519,278943229,279260106,279540301,279792388,279981216,280302579,280740690,281152680,281540021,281897522,282291148,282626344,282942003,283213444,283616180,283950256,284280595,284522106,284867019,285126663,285380042,285555208,285919466,286281394,286621940,286904355,287206263,287495250,287739010,287949492,288188864,288496776,288745793,288966528,289148495,289379917,289537112,289686853,289779241,290264164,290728431,291189192,291612705,292057580,292483955,292897553,293265912,293664292,294101799,294509453,294890300,295256176,295645199,295982828,296296138,296577868,297032448,297440114,297844340,298178576,298584871,298927022,299272787,299533144,299923888,300280947,300618781,300898605,301207646,301492789,301741098,301937026,302230441,302676899,303085712,303479438,303827283,304225887,304561785,304887572,305140149,305546114,305877116,306226001,306485760,306820100,307086545,307338311,307519541,307855769,308224480,308563352,308852313,309141784,309445857,309697538,309912371,310127047,310440892,310691173,310923308,311090624,311330332,311484503,311642255,311735957,312173250,312597758,313009122,313366218,313756294,314124841,314462598,314749948,315073263,315457008,315797705,316103055,316380620,316693933,316939867,317170944,317357466,317762326,318095045,318426305,318682568,319025386,319285880,319541545,319717233,320018826,320298129,320549199,320741151,320955110,321150265,321317465,321442627,321651889,322044890,322379689,322700586,322960422,323285256,323531837,323772176,323927072,324273670,324534366,324789035,324963532,325199833,325384084,325548958,325655212,325903211,326192880,326442201,326652084,326854000,327070529,327231308,327363000,327494989,327727168,327884684,328034052,328119238,328281274,328375157,328467903,328512920,328917742,329388576,329847564,330282334,330712994,331150722,331557508,331944196,332318476,332766234,333175337,333570101,333916526,334318141,334651874,334981758,335226933,335684384,336103769,336518277,336870652,337267436,337625596,337966746,338247533,338591095,338965879,339300723,339594693,339886512,340193024,340443089,340661726,340881510,341335960,341743724,342147386,342482205,342888439,343228883,343574592,343835512,344226838,344583832,344920532,345200972,345510563,345794936,346043169,346239640,346517997,346905790,347241877,347555173,347823386,348141021,348389800,348623472,348794583,349125490,349366139,349623813,349792767,350042347,350217063,350380986,350481736,350831904,351266252,351676359,352051182,352416846,352804135,353143157,353452025,353739533,354134240,354471633,354796244,355047722,355378741,355621162,355867677,356036135,356436957,356790794,357131456,357399720,357719216,357999986,358249247,358443225,358697979,358995532,359248946,359461065,359657618,359876828,360033458,360176174,360308944,360713536,361046317,361377790,361631761,361975354,362235016,362491306,362666612,362968744,363247928,363499709,363691047,363905731,364100986,364267108,364392347,364584064,364896069,365142708,365368668,365546671,365779513,365938159,366089391,366170691,366429944,366599112,366765036,366862082,367018263,367120628,367212953,367262750,367557748,367995647,368405945,368792193,369152382,369544649,369880700,370194093,370468330,370870603,371204498,371534451,371777222,372118789,372377699,372632649,372806208,373174024,373533415,373876079,374157588,374460457,374748245,374993753,375200225,375442728,375748237,375999489,376218919,376400750,376631038,376790360,376938188,377034250,377440264,377788742,378133152,378395034,378724177,378993516,379245931,379431958,379711989,379999951,380247230,380444551,380655857,380867627,381029888,381160376,381318272,381640765,381888512,382121368,382286045,382526688,382683865,382851782,382946483,383191686,383367085,383528335,383633692,383784076,383891274,383981651,384036023,384268817,384656361,384993054,385305530,385574513,385890553,386140413,386373528,386545605,386876118,387117326,387372826,387541754,387791325,387966457,388130413,388230506,388512454,388794740,389044759,389239577,389444120,389655169,389819372,389946171,390098350,390319217,390479426,390621929,390721715,390871910,390956279,391038430,391082185,391418724,391682197,391935629,392112043,392347840,392534583,392695732,392807578,392993996,393195169,393360379,393486782,393610900,393742361,393827699,393901614,393988327,394223886,394380052,394532941,394620273,394787991,394882309,394975358,395020786,395170141,395275618,395367254,395418271,395496827,395551287,395593225,395618428,395815003,396295778,396752543,397205572,397616765,398071467,398478993,398884970,399216546,399681163,400100850,400514139,400869529,401260608,401625264,401966026,402247031,402604798,403042628,403452372,403839003,404199368,404591331,404927319,405240995,405515161,405917455,406250986,406581297,406824253,407164035,407422522,407678402,407851066,408253215,408680017,409094143,409462708,409838402,410211798,410546598,410846204,411159191,411547204,411886219,412199516,412463966,412787360,413034034,413270882,413433413,413839448,414186175,414531059,414792035,415122754,415391483,415643265,415828894,416110885,416397762,416645660,416841264,417053608,417264731,417426945,417557120,417736109,418189605,418597984,419000281,419336731,419742745,420079430,420426024,420687012,421079903,421436488,421773237,422052382,422363759,422646248,422896264,423092190,423371539,423758424,424096119,424407583,424677544,424992004,425243064,425475505,425648575,425978503,426220510,426473718,426642695,426892574,427067753,427231961,427331386,427659770,428029486,428367197,428655857,428943923,429247567,429499996,429712477,429931436,430245485,430493506,430724601,430894569,431133308,431288591,431440934,431534910,431872844,432135720,432389030,432565902,432801130,432987789,433148700,433260868,433448383,433648258,433814005,433940239,434064786,434195825,434282281,434354758,434461310,434916771,435323556,435729824,436070680,436484879,436834613,437177866,437445721,437813375,438181181,438520127,438804776,439101452,439391338,439643671,439854674,440103961,440498014,440832689,441150686,441412198,441738236,441983636,442223814,442375452,442723372,442983096,443237147,443411752,443651183,443831617,443996826,444103388,444391785,444766615,445101388,445405902,445690886,445999916,446248124,446468734,446666727,446991373,447235113,447475204,447631290,447878242,448046634,448213945,448309523,448621013,448889142,449145047,449331740,449554304,449748101,449907469,450025417,450201357,450413245,450576283,450707893,450817999,450960631,451049025,451125202,451184599,451590697,451935569,452281074,452540949,452873116,453141141,453392342,453577707,453861472,454147485,454395870,454590970,454803362,455014431,455176252,455306980,455468369,455788767,456037021,456269762,456435442,456675748,456829346,456998093,457092231,457339051,457513296,457676604,457779277,457930923,458036822,458128372,458181937,458387762,458691036,458942582,459158330,459348547,459567946,459731870,459874916,459983283,460222128,460376353,460537009,460630797,460795670,460892269,460984376,461030102,461246796,461434402,461596718,461707822,461840184,461961464,462053744,462115973,462216719,462348474,462435894,462509078,462563412,462640643,462679873,462714991,462731476,463177006,463599655,464011488,464369791,464758802,465126947,465463535,465751886,466077919,466456375,466798477,467104502,467382742,467695229,467940285,468169748,468362078,468765366,469099155,469430531,469678752,470023658,470284844,470539576,470714796,471016713,471297378,471549228,471738860,471955405,472152047,472314020,472438896,472654553,473048611,473383576,473700180,473963039,474288744,474534060,474773499,474926403,475272585,475532244,475785855,475960879,476200828,476380294,476545532,476652475,476905906,477194792,477438514,477649474,477854000,478068121,478229340,478362613,478495185,478727114,478883571,479034082,479121681,479276514,479370425,479463768,479507969,479874093,480231517,480574395,480855205,481158722,481446859,481693533,481895110,482140747,482447041,482697482,482916692,483096927,483328882,483488129,483634053,483733921,484065718,484318529,484576156,484745484,484993866,485169185,485331348,485436774,485649798,485840608,486001606,486114493,486248285,486373472,486463328,486529102,486666998,486986389,487234653,487467926,487633511,487873893,488025709,488194616,488288613,488535807,488709740,488873653,488975741,489127753,489233770,489325247,489378815,489542290,489752435,489916506,490044466,490164239,490296483,490386704,490460602,490523648,490674077,490757888,490843357,490887048,490979851,491024345,491067568,491084775,491409086,491777923,492115537,492402892,492693537,492993332,493246741,493457979,493680387,493993709,494240411,494471136,494643506,494880505,495036491,495188163,495279793,495620292,495881378,496136371,496312451,496547742,496733538,496896630,497006505,497197169,497393243,497560252,497685595,497810912,497941139,498029386,498099651,498202704,498527305,498774016,499014427,499170679,499428653,499598635,499764588,499861971,500089557,500274852,500439452,500546066,500687933,500800877,500889218,500951169,501097183,501314477,501474925,501607254,501719281,501862568,501949270,502028287,502068454,502231451,502325437,502417772,502463190,502552466,502598847,502642238,502661429,502903648,503192440,503436430,503646160,503851889,504064750,504227055,504359603,504492738,504723897,504881473,505030931,505119652,505272585,505366559,505459897,505504039,505741864,505918639,506083166,506188879,506333704,506445700,506534041,506589918,506704636,506831121,506921518,506987231,507046906,507119816,507161380,507193117,507233283,507474739,507634648,507802566,507897047,508059882,508157680,508247501,508297266,508439923,508547909,508637536,508692163,508765162,508827326,508869274,508896128,508976461,509111685,509201303,509276620,509326238,509406391,509441862,509484760,509501422,509593083,509638416,509681374,509699045,509739874,509759108,509775355,509781602,510039529,510533062,511016960,511497510,511957181,512438179,512896123,513350669,513759548,514242831,514699155,515160029,515578028,516031989,516456007,516867675,517224783,517653835,518126980,518584733,519021868,519448177,519892066,520303697,520691879,521054973,521505184,521913271,522314586,522654260,523059043,523391830,523723142,523978579,524450737,524916576,525376522,525802919,526243482,526676468,527086384,527459365,527847926,528285742,528700404,529088391,529444825,529837870,530172660,530493275,530762021,531216614,531624266,532030271,532365487,532782647,533132405,533474798,533741703,534112100,534478756,534818810,535100567,535400879,535690293,535939233,536148997,536419169,536899945,537356876,537807221,538220897,538675479,539082857,539488157,539820331,540282910,540702427,541114434,541470997,541863895,542224232,542566183,542848038,543208838,543646419,544053369,544439649,544802528,545191846,545529561,545843410,546118292,546519725,546853761,547183382,547428219,547759732,548019312,548275604,548446618,548856357,549283182,549695798,550064160,550440319,550814971,551149894,551443139,551761209,552150169,552487923,552800463,553064837,553388077,553635566,553869162,554037500,554443723,554783453,555129136,555390228,555722862,555990692,556239035,556425683,556712644,556996763,557245033,557441820,557651046,557861868,558023460,558154377,558342937,558824934,559282052,559736908,560145118,560601329,561007366,561425803,561774556,562216088,562641408,563051773,563414907,563799783,564168967,564507139,564796135,565133891,565579956,565990265,566381326,566732542,567127356,567464443,567789187,568045319,568451322,568783415,569120043,569378807,569718434,569982334,570235711,570411733,570785808,571219890,571628998,572002989,572370118,572752375,573093017,573399175,573693480,574087704,574421317,574745592,575001873,575329824,575573419,575814846,575977215,576387469,576736424,577080598,577348508,577666411,577945756,578197492,578388533,578650920,578940131,579195158,579406212,579604355,579822689,579981992,580118477,580265895,580720544,581128132,581534136,581867144,582285783,582635072,582977405,583243605,583615918,583981071,584321599,584602269,584904178,585193209,585441129,585651187,585907965,586300142,586636120,586949634,587215583,587540324,587785100,588024301,588180081,588520874,588779756,589035080,589208335,589450873,589626934,589793907,589899794,590195214,590569102,590903221,591203699,591492463,591797537,592049109,592268412,592468192,592791277,593037952,593275205,593434660,593675146,593842449,594010075,594104448,594421449,594690545,594942653,595128534,595353570,595546771,595707169,595820233,596000160,596211643,596373868,596504228,596617918,596756784,596846358,596920302,596989638,597472984,597933290,598395347,598816443,599265781,599691838,600100275,600468425,600873669,601309561,601718170,602093644,602462233,602849499,603186543,603498497,603788161,604239835,604648975,605051711,605388426,605794116,606125595,606470412,606730045,607126878,607483586,607822532,608095139,608410061,608692600,608942701,609137607,609436652,609883081,610293508,610684050,611035983,611430927,611767771,612091927,612348959,612754804,613087008,613421479,613680733,614020892,614284114,614537511,614714086,615061709,615430124,615766508,616055078,616347119,616642502,616895805,617108483,617332411,617645744,617889469,618121410,618295605,618530723,618687275,618839899,618926692,619380985,619800996,620215340,620572359,620960579,621327984,621667064,621952176,622282594,622657670,622999827,623304837,623583903,623896753,624143366,624367723,624566432,624969223,625303355,625634263,625874652,626223478,626483232,626737664,626912008,627220642,627495962,627749408,627936745,628157618,628352543,628510139,628635079,628859302,629251033,629587092,629900948,630166456,630491202,630735375,630975088,631131534,631470602,631728985,631985113,632157494,632400750,632575983,632743285,632849141,633108042,633395387,633642074,633846345,634054350,634265881,634429465,634561026,634695023,634926160,635085453,635232267,635323304,635475417,635565849,635659450,635703240,636111469,636537952,636949704,637316883,637695371,638068724,638404451,638693688,639015597,639403404,639741198,640052831,640319714,640640604,640888968,641121368,641292622,641698630,642034561,642381592,642642283,642975676,643242631,643492491,643676732,643966650,644248866,644499268,644694941,644902804,645112658,645276218,645405066,645588955,645983872,646322462,646647254,646898726,647228422,647470844,647723603,647892349,648223928,648491348,648743435,648921173,649155867,649343769,649506009,649617379,649841651,650144563,650397155,650609430,650804088,651024137,651183541,651325385,651439488,651677730,651833275,651985039,652079024,652245575,652340564,652432899,652479059,652811823,653180324,653516456,653805314,654097957,654391809,654646031,654858434,655083396,655396202,655640610,655871053,656046339,656280150,656437876,656590009,656675441,657019681,657280606,657535659,657710879,657944921,658131500,658295456,658403225,658598040,658794546,658957094,659082341,659208073,659339424,659428075,659495639,659605770,659931700,660177060,660417063,660569031,660826578,660995539,661160971,661258455,661491480,661671703,661836941,661943664,662087287,662199344,662284932,662347091,662498532,662712763,662873683,663006824,663117823,663260724,663346117,663426454,663471240,663627429,663721286,663814631,663858893,663949226,663995073,664038071,664057086,664376400,664850932,665307697,665751036,666175471,666622187,667032329,667426581,667777926,668232064,668639701,669044304,669378136,669784279,670128351,670473991,670733624,671158335,671584405,671995742,672362601,672742246,673115028,673451072,673740183,674062282,674450250,674787530,675099541,675366691,675686654,675934858,676167798,676340256,676796489,677205088,677623616,677973047,678375868,678731568,679069745,679346649,679702397,680071218,680409878,680698840,680989560,681293028,681544850,681760543,681987917,682382214,682721166,683045864,683297570,683627530,683869935,684120687,684289128,684622548,684888687,685141428,685317922,685553814,685741113,685903359,686014286,686291256,686736360,687147558,687536038,687890398,688284825,688620588,688943417,689203475,689608487,689941284,690272367,690531336,690872844,691134633,691389049,691565566,691914850,692282759,692619667,692907573,693201072,693492951,693748245,693959970,694186047,694498280,694743673,694972476,695148905,695381656,695540468,695691820,695776257,696189968,696540368,696882738,697150686,697467253,697747788,697999790,698188908,698454929,698745055,698995966,699206402,699406407,699624378,699784450,699917538,700060912,700386483,700631865,700871244,701024374,701279747,701448675,701613937,701711624,701945590,702124754,702289963,702396954,702540492,702652498,702738105,702800041,703020457,703468898,703877334,704272315,704618748,705020854,705353880,705684653,705928760,706338572,706686453,707030452,707293985,707621209,707890066,708144353,708331082,708647618,709021827,709356567,709652518,709943019,710249504,710499654,710718808,710918345,711243007,711489717,711725224,711886465,712128118,712289297,712457216,712551597,712930883,713287948,713626129,713905892,714214739,714499906,714748155,714944021,715194941,715499976,715748755,715967490,716153598,716378329,716539318,716683795,716792856,717123865,717364457,717624037,717792987,718042731,718216914,718380971,718482567,718701704,718888854,719052404,719164597,719294757,719419653,719511304,719574712,719739008,720133417,720471767,720796520,721048193,721378517,721620922,721869673,722037932,722373066,722638084,722891277,723066683,723303472,723490175,723652373,723763268,723991756,724291298,724544710,724756125,724952688,725171943,725329893,725472129,725588985,725825753,725981704,726133537,726224498,726391830,726486047,726579254,726624781,726912369,727191777,727442536,727634806,727848523,728044028,728211175,728336389,728497607,728715047,728874306,729012636,729120532,729263753,729352053,729432347,729468773,729727029,729896856,730062814,730160085,730314871,730418631,730510746,730560820,730692470,730805314,730893402,730955300,731026713,731090858,731132750,731159671,731270627,731725355,732132698,732538141,732869992,733285783,733634656,733975473,734243273,734619696,734981017,735322230,735604466,735906621,736195229,736439518,736648502,736911809,737301699,737638793,737952870,738217720,738541545,738786682,739025386,739184694,739517638,739777118,740033473,740204484,740449005,740625905,740790186,740895898,741197331,741572169,741906970,742201442,742492857,742799525,743049570,743268343,743469170,743793251,744040334,744274617,744437287,744678516,744837819,745005764,745100359,745422660,745690545,745939430,746125916,746354431,746544523,746705476,746819091,746998242,747209218,747370138,747501590,747617911,747752980,747843039,747918071,747993663,748399656,748730760,749078626,749338305,749672640,749939447,750191183,750371561,750665032,750946617,751197583,751392553,751597869,751808643,751972599,752099943,752274699,752588859,752838276,753070295,753237606,753477717,753631842,753788643,753882442,754134760,754306829,754472123,754570268,754724734,754830506,754920496,754973735,755190541,755488613,755741939,755953848,756150306,756369656,756526562,756669184,756787185,757023390,757179246,757331612,757420869,757588409,757682408,757775742,757821162,758042729,758228094,758392257,758501306,758640135,758752504,758845093,758907264,759012033,759142824,759231274,759300425,759358581,759433235,759473727,759508668,759521065,759938554,760288252,760630610,760897229,761216695,761494092,761747192,761934241,762204196,762493394,762741877,762951561,763154363,763370201,763531320,763663081,763809912,764134693,764379870,764618735,764773869,765025309,765193823,765360146,765456738,765693038,765869858,766036429,766142675,766287210,766398261,766485925,766544872,766735165,767040977,767292017,767511608,767693460,767923883,768082966,768230707,768324076,768564496,768733252,768900674,768995347,769156716,769255372,769346386,769396016,769596752,769790609,769950625,770064488,770199076,770324740,770415167,770480511,770567192,770707038,770796465,770870626,770919459,771000062,771037520,771081196,771097936,771419640,771687409,771935565,772122357,772351501,772541053,772702494,772816177,772995279,773205848,773367834,773498340,773615747,773749180,773840029,773914476,773984210,774223705,774376329,774541389,774635376,774798935,774896582,774988205,775034769,775181020,775287974,775378362,775431875,775502931,775565093,775608084,775633618,775751662,775972670,776133120,776275748,776375084,776525529,776609848,776692360,776736114,776902192,776997418,777089754,777135668,777222364,777272160,777314130,777334784,777452493,777569193,777661528,777724388,777793091,777858974,777898215,777929437,777969705,778045596,778085030,778121310,778135337,778179010,778195726,778212307,778217461,778598526,779071012,779529063,779965791,780393484,780831343,781245323,781633219,781999452,782449173,782856828,783255918,783598695,784001282,784335661,784666726,784907944,785372074,785792027,786205243,786560449,786951336,787316149,787656917,787937827,788275302,788650132,788986849,789290590,789574945,789884814,790133098,790352939,790562984,791017551,791424673,791830192,792162419,792576297,792923899,793266875,793532234,793911626,794269809,794613297,794894298,795197534,795484809,795731166,795936234,796203298,796591294,796930365,797243679,797508366,797831571,798078204,798315228,798476789,798807934,799065440,799322502,799492189,799738964,799915109,800078504,800183647,800512699,800950186,801358116,801734621,802104153,802492524,802830218,803141873,803420617,803820930,804156782,804481447,804731877,805062958,805309283,805567487,805737423,806124099,806480789,806817371,807096969,807408024,807690917,807940601,808136561,808386501,808690646,808940867,809158060,809346924,809567442,809730834,809874119,809990123,810395705,810727338,811071354,811330944,811665179,811932912,812184763,812363564,812659013,812941455,813191535,813386124,813591491,813801141,813965705,814091848,814270167,814584453,814832500,815063606,815233244,815472247,815627419,815780254,815874228,816127918,816299019,816464256,816563175,816716805,816822524,816912146,816965650,817237937,817679749,818091419,818480689,818835875,819230109,819562970,819887325,820149841,820553901,820886936,821218639,821469340,821813785,822074304,822329769,822505123,822857791,823225446,823564473,823849273,824145777,824435485,824688368,824899366,825128239,825441234,825687772,825911732,826090550,826324525,826482253,826633345,826714100,827133656,827482504,827824375,828091102,828412638,828687576,828940937,829128480,829400034,829688900,829934626,830145280,830349318,830563930,830724904,830857746,831005575,831330287,831574223,831814208,831970134,832217560,832385764,832552966,832648755,832886954,833062473,833229402,833335203,833480062,833591251,833679715,833736800,833954264,834342436,834681203,834994454,835258437,835582151,835828846,836065308,836227791,836559121,836814438,837071853,837241000,837488953,837664431,837827398,837932406,838200376,838486378,838734585,838929673,839142336,839353440,839515484,839646070,839786784,840013448,840174532,840318146,840414772,840565969,840647994,840741902,840785736,841110449,841377304,841627630,841811209,842042436,842229722,842393141,842505569,842684615,842894362,843058169,843186734,843305801,843437263,843529041,843603028,843675465,843914197,844068520,844229638,844323460,844488108,844584924,844676996,844722776,844870561,844976826,845067161,845120206,845193796,845253177,845296391,845321616,845492093,845942497,846351457,846752857,847091425,847496784,847829337,848160731,848420311,848826784,849179107,849519968,849789580,850107729,850388173,850637103,850831301,851122010,851500952,851842752,852149018,852427105,852739600,852984377,853214320,853400571,853726800,853972026,854213031,854371083,854628321,854798470,854964494,855062200,855407194,855775423,856114324,856398400,856695560,856985877,857237502,857448319,857678248,857991270,858238133,858460823,858641236,858874708,859032310,859182703,859265061,859611606,859871328,860125099,860300034,860539837,860719603,860884812,860991648,861193460,861388385,861544458,861669609,861799980,861927154,862016772,862084039,862212753,862615037,862947847,863278864,863522350,863858859,864117699,864374134,864545817,864863272,865131753,865386717,865573410,865795870,865990124,866149497,866266586,866479831,866785979,867036522,867255701,867436187,867668037,867827295,867973353,868070005,868311462,868473758,868641784,868735959,868898872,868996649,869086883,869136548,869398800,869684444,869932778,870128238,870339681,870550705,870712162,870843120,870985012,871210593,871371612,871515758,871612404,871763546,871844353,871938336,871982106,872228427,872402410,872566267,872668321,872820144,872926008,873017726,873071329,873186684,873311448,873403111,873466682,873532762,873599283,873641250,873672473,873739610,874145008,874477081,874817838,875076665,875413894,875679677,875932583,876108571,876407685,876688872,876938892,877132245,877340743,877546370,877711562,877836732,878019047,878332396,878579395,878809979,878982243,879219453,879375394,879526866,879619112,879874283,880044168,880210555,880308855,880462403,880567621,880658690,880710796,880935686,881226833,881482498,881693936,881891706,882109524,882268216,882407019,882530497,882762795,882921935,883073043,883157314,883325400,883420013,883512659,883557950,883781696,883967379,884131880,884238722,884380281,884493386,884581891,884643834,884751410,884881219,884970521,885036949,885097223,885171434,885211394,885245677,885263625,885608349,885867972,886121315,886296517,886536766,886715739,886881003,886988160,887190541,887385381,887541676,887665899,887797038,887923461,888014060,888080718,888185101,888416477,888573773,888723368,888811709,888965258,889059222,889152560,889196713,889355285,889454112,889545675,889595471,889677251,889730745,889771985,889793746,889943227,890155904,890318305,890449810,890559973,890702512,890791274,890866535,890920183,891072827,891159506,891253129,891297113,891388632,891434051,891476076,891495088,891634982,891743108,891832736,891887351,891960407,892022569,892064528,892091380,892143962,892212194,892254142,892286079,892308187,892343186,892355544,892371888,892376924,892802152,893227015,893637388,894001685,894385932,894754645,895093463,895382430,895702687,896089509,896428436,896737947,897009900,897323766,897573945,897806050,897984662,898390237,898722319,899061283,899319644,899658314,899922889,900176178,900351397,900651837,900932689,901182634,901376074,901585568,901789738,901954948,902080728,902280406,902674685,903009617,903333188,903588904,903917450,904161074,904401987,904566986,904908756,905169174,905424910,905600521,905835729,906021222,906184943,906294147,906532680,906821819,907078109,907289191,907487505,907705199,907864592,908002402,908126979,908359409,908518473,908669740,908752210,908920774,909015034,909107657,909152855,909498481,909865472,910205350,910487465,910787353,911076963,911326148,911536011,911769870,912080857,912328830,912548353,912731723,912963831,913121319,913270925,913357122,913700098,913959525,914213555,914388125,914629333,914807045,914973282,915079711,915283198,915477324,915634725,915757012,915888830,916014594,916105818,916172026,916294510,916618028,916863556,917101788,917260224,917501390,917670305,917837510,917932498,918172409,918349487,918513784,918619413,918764911,918876562,918965334,919020279,919179937,919392274,919554570,919685393,919797177,919937976,920027101,920101734,920157176,920309283,920394621,920488244,920532286,920623802,920669228,920711179,920730194,921034910,921406604,921742517,922032594,922325046,922630201,922878663,923097785,923306306,923623801,923872691,924106237,924272332,924512294,924664236,924830626,924924613,925252747,925519695,925771487,925951629,926184484,926372408,926535184,926647231,926825112,927036000,927199951,927327203,927447544,927580691,927669362,927743250,927826431,928157509,928399933,928646212,928814724,929068463,929240279,929405560,929503895,929728461,929915149,930076717,930188215,930322959,930440512,930532863,930595641,930731438,930950713,931107189,931249918,931354306,931500570,931585941,931667727,931707588,931875050,931969036,932062415,932107912,932194278,932243899,932286884,932306402,932530779,932819891,933075398,933286467,933484621,933702863,933862181,933998773,934124286,934357338,934515900,934667107,934748269,934917110,935011161,935103782,935148926,935376319,935558849,935724033,935829772,935973291,936085305,936172958,936234928,936344526,936472832,936562529,936628860,936689143,936763118,936802692,936837369,936859155,937109815,937278249,937444736,937541189,937700519,937798765,937891981};
long long calc(long a)
{
long block = a / 500000;
long start = block * 500000;
long long ans = f[block];
long end = start + a % 500000;
for (long i=start+1;i<end+1;i++)
{
long tmp = i;
long cnt1 = 0;
long cnt2 = 0;
while (tmp)
{
if (tmp & 1)
cnt2 ++;
else
cnt1 ++;
tmp >>= 1;
}
if (cnt1 >= cnt2)
ans ++;
}
return ans;
}
int main()
{
freopen("rndnum.in","r",stdin);
freopen("rndnum.out","w",stdout);
long l,r;
scanf("%ld%ld",&l,&r);
l --;
cout << calc(r)-calc(l);
return 0;
}