HDU 4389 X mod f(x) 平方分割 数位DP

来源:互联网 发布:ssh2权限管理系统源码 编辑:程序博客网 时间:2024/04/30 04:26

题意:给出范围A-B,求出该范围内中有多少个数满足,自己被自己所有位数的和整除。

思路:有两种方法,1.可以通过平方分割的方法打巨表 2. 数位DP

代码如下:

平方分割的:

#include <cstdio>#include <algorithm>using namespace std;const int BASE = 400000;int a[]={0,43691,79494,117251,154753,186561,226142,259122,293749,328266,357923,394196,424906,456935,489121,516988,550627,579518,609471,639668,666027,697359,724669,752684,781082,806095,847505,881829,917958,953748,984457,1022150,1053893,1087182,1120224,1148898,1183663,1213284,1244283,1275181,1302141,1334553,1362477,1391506,1420620,1446173,1476483,1502903,1530199,1557612,1581855,1621202,1654240,1688855,1723174,1752886,1788901,1819529,1851587,1883358,1911166,1944532,1973139,2003059,2032861,2059035,2090283,2117319,2145464,2173585,2198383,2227715,2253328,2279834,2306406,2329984,2367444,2399319,2432533,2465529,2494379,2528778,2558405,2589245,2619881,2646896,2678924,2706624,2735522,2764291,2789743,2819833,2846056,2873233,2900473,2924630,2952939,2977813,3003491,3029225,3052160,3087935,3118775,3150784,3182541,3210653,3243650,3272346,3302173,3331742,3358037,3388829,3415677,3443601,3471414,3496170,3525126,3550533,3576928,3603263,3626798,3654135,3678248,3703248,3728163,3750525,3784857,3814795,3845731,3876416,3903809,3935541,3963419,3992271,4020913,4046550,4076225,4102288,4129399,4156326,4180462,4208446,4233077,4258729,4284236,4307251,4333726,4357099,4381443,4405618,4427492,4460526,4489698,4519477,4549222,4575951,4606580,4633801,4661706,4689473,4714477,4743148,4768606,4794821,4820985,4844581,4871639,4895644,4920601,4945346,4967829,4993494,5016303,5040064,5063546,5084970,5116842,5145295,5174152,5203052,5229087,5258689,5285249,5312261,5339278,5363730,5391460,5416390,5441864,5467241,5490370,5516543,5540019,5564270,5588334,5610431,5635301,5657629,5680733,5703586,5724686,5755509,5783154,5811019,5839203,5864428,5893125,5919016,5945229,5971571,5995318,6022241,6046569,6071352,6096132,6118762,6144152,6167148,6190748,6214207,6235854,6259936,6281842,6304401,6326727,6347468,6377364,6404220,6431293,6458763,6483225,6511123,6536365,6561819,6587544,6610705,6636874,6660672,6684816,6709022,6731176,6755843,6778405,6801426,6824364,6845573,6868982,6890536,6912509,6934386,6954793,6996285,7030588,7066672,7102619,7133324,7171148,7202960,7236173,7269451,7298238,7333102,7362912,7393745,7424845,7451901,7484336,7512453,7541342,7570617,7596271,7626540,7653107,7680213,7707794,7732131,7771537,7804493,7839107,7873447,7903158,7939289,7969917,8001955,8033854,8061674,8095190,8123944,8153844,8183759,8209989,8241296,8268482,8296532,8324781,8349662,8379035,8404796,8431245,8457899,8481543,8519098,8550862,8584112,8617098,8645838,8680430,8709973,8740833,8771553,8798508,8830751,8858566,8887488,8916325,8941769,8972020,8998341,9025589,9052898,9077035,9105507,9130510,9156211,9182051,9205050,9240868,9271565,9303493,9335273,9363199,9396299,9424902,9454621,9484265,9510443,9541425,9568346,9596276,9624166,9648877,9678043,9703588,9729925,9756386,9779898,9807402,9831686,9856617,9881674,9904095,9938397,9968116,9998988,10029631,10056856,10088643,10116381,10145145,10173779,10199288,10229102,10255201,10282245,10309229,10333318,10361462,10386204,10411833,10437437,10460350,10486974,10510525,10534804,10559107,10581019,10613991,10642859,10672739,10702398,10728985,10759579,10786514,10814375,10842081,10866960,10895746,10921080,10947378,10973539,10997055,11024236,11048231,11073146,11097967,11120363,11146143,11169032,11192779,11216341,11237788,11269585,11297740,11326535,11355287,11381211,11410781,11437061,11464064,11490945,11515232,11543049,11567757,11593240,11618613,11641607,11667918,11691349,11715602,11739665,11761612,11786589,11808873,11831994,11854914,11875940,11906656,11934148,11962036,11990033,12015315,12043940,12069608,12095783,12121935,12145732,12172719,12196860,12221682,12246341,12268919,12294425,12317326,12340947,12364355,12385962,12410178,12432031,12454619,12476902,12497616,12527353,12554144,12581112,12608409,12632958,12660699,12685745,12711187,12736708,12759893,12786075,12809685,12833815,12857891,12880002,12904723,12927189,12950227,12973061,12994262,13017779,13039220,13061255,13083081,13103432,13132276,13158335,13184533,13211156,13235027,13261988,13286411,13311112,13336038,13358682,13384129,13407262,13430808,13454333,13475977,13500029,13522081,13544566,13566939,13587773,13610626,13631739,13653298,13674680,13694682,13734267,13767294,13801878,13836441,13866076,13902362,13933165,13965103,13997313,14025210,14058750,14087732,14117512,14147718,14174040,14205324,14232672,14260578,14289069,14314021,14343280,14369176,14395419,14422249,14446019,14483711,14515465,14548726,14581794,14610415,14645165,14674847,14705770,14736685,14763678,14795996,14823965,14852859,14881928,14907435,14937719,14964213,14991343,15018851,15043070,15071492,15096609,15122242,15148222,15171368,15207384,15238019,15270013,15301812,15329564,15362913,15391574,15421399,15451178,15477345,15508514,15535557,15563571,15591642,15616379,15645701,15671355,15697747,15724381,15747911,15775517,15799935,15824853,15850059,15872614,15907024,15936647,15967434,15998072,16025027,16056991,16084755,16113516,16142250,16167641,16197631,16223831,16250869,16278049,16302070,16330366,16355271,16380791,16406613,16429517,16456244,16479983,16504230,16528691,16550673,16583699,16612400,16642250,16671790,16698107,16728845,16755720,16783579,16811365,16836156,16865056,16890441,16916672,16942941,16966346,16993660,17017790,17042636,17067650,17089987,17115854,17138920,17162506,17186266,17207734,17239530,17267410,17296322,17324932,17350626,17380295,17406387,17433471,17460354,17484533,17512481,17537112,17562651,17588130,17611005,17637428,17660865,17685042,17709272,17731162,17756275,17778684,17801810,17824897,17845948,17876646,17903888,17931840,17959595,17984678,18013351,18038791,18065077,18091173,18114815,18141878,18165900,18190692,18215408,18237861,18263458,18286315,18309921,18333446,18354881,18379226,18401113,18423629,18446118,18466778,18496484,18523079,18550157,18577178,18601707,18629495,18654336,18679853,18705222,18728405,18754638,18778131,18802361,18826354,18848449,18873277,18895649,18918653,18941517,18962677,18986343,19007778,19029803,19051715,19072027,19100793,19126725,19152973,19179295,19203124,19230047,19254279,19279094,19303864,19326482,19351957,19374910,19398472,19421889,19443553,19467689,19489599,19512107,19534431,19555170,19578177,19599194,19620739,19642193,19662166,19690109,19715335,19740854,19766562,19789801,19815970,19839693,19863795,19887954,19910096,19934836,19957322,19980377,20003301,20024535,20048008,20069555,20091499,20113360,20133785,20156182,20176871,20197957,20218955,20238658,20276474,20308298,20341515,20374879,20403565,20438435,20468322,20499199,20530382,20557471,20589807,20617983,20646853,20676155,20701761,20731987,20758602,20785688,20813311,20837653,20865971,20891179,20916739,20942775,20966010,21002118,21032794,21064811,21096764,21124505,21157999,21186808,21216716,21246708,21272915,21304162,21331393,21359396,21387635,21412464,21441774,21467540,21493961,21520686,21544298,21571860,21596331,21621310,21646585,21669203,21703785,21733379,21764279,21795033,21821937,21854138,21881994,21910877,21939795,21965192,21995366,22021733,22048923,22076230,22100308,22128735,22153714,22179410,22205350,22228315,22255124,22278956,22303284,22327830,22349898,22383021,22411660,22441419,22471054,22497209,22528142,22555121,22582999,22610931,22635611,22664678,22690219,22716482,22742926,22766328,22793830,22818101,22842997,22868151,22890498,22916487,22939669,22963331,22987254,23008770,23040600,23068330,23097216,23125826,23151361,23181131,23207304,23234352,23261322,23285374,23313401,23338160,23363703,23389295,23412111,23438661,23462218,23486441,23510842,23532684,23557860,23580430,23603442,23626681,23647763,23678448,23705412,23733400,23761108,23786035,23814784,23840165,23866502,23892615,23916158,23943279,23967288,23992177,24016985,24039334,24065037,24087921,24111536,24135228,24156609,24181011,24202990,24225535,24248152,24268780,24298444,24324774,24351925,24378830,24403174,24431019,24455758,24481341,24506707,24529756,24556062,24579471,24603716,24627767,24649665,24674597,24696961,24720025,24743030,24764046,24787757,24809226,24831203,24853246,24873479,24902193,24927930,24954234,24980376,25004239,25031235,25055441,25080389,25105028,25127672,25153210,25176098,25199771,25223184,25244759,25268986,25290903,25313414,25335824,25356565,25379652,25400691,25422265,25443768,25463707,25491533,25516628,25542227,25567704,25590933,25617079,25640691,25664907,25688966,25711100,25735876,25758309,25781369,25804208,25825376,25848872,25870327,25892397,25914260,25934669,25957180,25977845,25998952,26019975,26039575,26066610,26091078,26115969,26140806,26163518,26188920,26212033,26235649,26259110,26280781,26304840,26326866,26349393,26371713,26392515,26415406,26436508,26458035,26479449,26499504,26521437,26541783,26562495,26583117,26602369,26638678,26669440,26701348,26733646,26761451,26795069,26824033,26853835,26884134,26910481,26941765,26969099,26997085,27025573,27050529,27079810,27105695,27131991,27158874,27182620,27210051,27234577,27259484,27284778,27307487,27342246,27371903,27402735,27433716,27460604,27492956,27520905,27549811,27578970,27604488,27634753,27661190,27688357,27715844,27740021,27768475,27793575,27819304,27845330,27868454,27895158,27919017,27943304,27967856,27990025,28023367,28052021,28081802,28111617,28137692,28168867,28195927,28223883,28252026,28276739,28306017,28331609,28358031,28384639,28408093,28435724,28460059,28485066,28510350,28532834,28558874,28582095,28605898,28629827,28651439,28683409,28711167,28739895,28768641,28794004,28823961,28850148,28877178,28904370,28928375,28956620,28981458,29006992,29032785,29055572,29082303,29105955,29130263,29154857,29176722,29201998,29224662,29247758,29271105,29292198,29322941,29349866,29377745,29405511,29430277,29459145,29484576,29510798,29537081,29560539,29587802,29611888,29636775,29661720,29683980,29709840,29732825,29756460,29780358,29801754,29826285,29848389,29870926,29893660,29914298,29943968,29970131,29997172,30024070,30048258,30076152,30100809,30126409,30151875,30174775,30201167,30224581,30248801,30273003,30294831,30319878,30342269,30365370,30388535,30409484,30433313,30454859,30476902,30499097,30519347,30548038,30573588,30599841,30625960,30649620,30676617,30700676,30725494,30750176,30772617,30798225,30821076,30844722,30868228,30889653,30913940,30935793,30958350,30980916,31001498,31024697,31045765,31067302,31088960,31108837,31136670,31161650,31187160,31212526,31235760,31261945,31285469,31309744,31333740,31355812,31380652,31403020,31426081,31448928,31470052,31493697,31515138,31537227,31559193,31579509,31602128,31622772,31643963,31665099,31684643,31711588,31735936,31760800,31785514,31808192,31833579,31856613,31880185,31903575,31925208,31949303,31971231,31993789,32016073,32036810,32059820,32080834,32102454,32123923,32143901,32165969,32186263,32206973,32227673,32246926,32273125,32296898,32321091,32345206,32367418,32392077,32414661,32437701,32460507,32481722,32505130,32526674,32548689,32570525,32590908,32613285,32633998,32655119,32676142,32695804,32717320,32737279,32757589,32777867,32796782,32831723,32861562,32892314,32923576,32950587,32983056,33011185,33040032,33069457,33095113,33125420,33152004,33179106,33206772,33231148,33259527,33284746,33310319,33336348,33359587,33386160,33410029,33434234,33458691,33480907,33514419,33543201,33573030,33603070,33629225,33660544,33687732,33715702,33744062,33768904,33798263,33824024,33850393,33877142,33900799,33928409,33952831,33977828,34003113,34025744,34051684,34074950,34098583,34122425,34144108,34176351,34204189,34233000,34261927,34287282,34317502,34343813,34370928,34398329,34422414,34450845,34475787,34501433,34527350,34550325,34577182,34600931,34625303,34649897,34671945,34697227,34719928,34743095,34766343,34787529,34818475,34845427,34873249,34901194,34925813,34954901,34980410,35006616,35033109,35056488,35083938,35108153,35132964,35158084,35180431,35206472,35229559,35253233,35277163,35298620,35323233,35345370,35367853,35390621,35411317,35441115,35467282,35494213,35521271,35545295,35573351,35598133,35623598,35649233,35672064,35698589,35722105,35746315,35770670,35792513,35817732,35840225,35863275,35886564,35907566,35931483,35953121,35975125,35997311,36017597,36046372,36071824,36098003,36124188,36147675,36174796,36198859,36223667,36248505,36270874,36296597,36319477,36343046,36366688,36388092,36412552,36434468,36457033,36479730,36500333,36523599,36544733,36566259,36587940,36607817,36635651,36660512,36685902,36711328,36734324,36760598,36784091,36808240,36832351,36854284,36879205,36901532,36924560,36947571,36968561,36992339,37013803,37035786,37057891,37078147,37100825,37121519,37142648,37163802,37183292,37210290,37234580,37259329,37284008,37306604,37332079,37355065,37378643,37402066,37423645,37447865,37469765,37492186,37514596,37535283,37558417,37579470,37601072,37622631,37642603,37664785,37685074,37705803,37726520,37745713,37771885,37795610,37819735,37843773,37865914,37890635,37913119,37936073,37958895,37980059,38003568,38025038,38047017,38068897,38089202,38111695,38132352,38153461,38174542,38194179,38215865,38235791,38256079,38276374,38295232,38320652,38343883,38367397,38390856,38412552,38436529,38458594,38481033,38503334,38524132,38546969,38568108,38589540,38610936,38630964,38652895,38673224,38693899,38714542,38733828,38754988,38774610,38794522,38814416,38832914,38866580,38895473,38925334,38955594,38981897,39013256,39040565,39068626,39097168,39122221,39151575,39177438,39203819,39230638,39254476,39281977,39306471,39331390,39356648,39379416,39405096,39428324,39451847,39475610,39497335,39529700,39557576,39586532,39615639,39641115,39671444,39697856,39725061,39752597,39776869,39805349,39830396,39856125,39882122,39905236,39932013,39955811,39980157,40004705,40026905,40051986,40074680,40097693,40120863,40142121,40173313,40200321,40228316,40256416,40281128,40310436,40336013,40362484,40389109,40412657,40440292,40464603,40489642,40514865,40537361,40563443,40586592,40610365,40634274,40655927,40680468,40702596,40725160,40747843,40768651,40798637,40824799,40851868,40879033,40903033,40931302,40956085,40981644,41007421,41030286,41057025,41080640,41104921,41129404,41151325,41176627,41199161,41222298,41245644,41266742,41290666,41312303,41334288,41356495,41376852,41405718,41431167,41457406,41483713,41507137,41534412,41558492,41583358,41608330,41630662,41656523,41679473,41703128,41726910,41748361,41772933,41794921,41817447,41840178,41860855,41884163,41905288,41926820,41948551,41968476,41996385,42021079,42046600,42072111,42095005,42121382,42144788,42168997,42193243,42215075,42240135,42262507,42285566,42308706,42329738,42353590,42375037,42397127,42419310,42439557,42462306,42482978,42504012,42525255,42544806,42571838,42595951,42620738,42645528,42667971,42693529,42716403,42739987,42763519,42784944,42809257,42831123,42853637,42876192,42896829,42920057,42941060,42962628,42984287,43004191,43026393,43046644,43067323,43088108,43107279,43133517,43157106,43181257,43205331,43227382,43252186,43274585,43297601,43320506,43341612,43365244,43386674,43408648,43430648,43450971,43473620,43494233,43515423,43536600,43556222,43577916,43597783,43617993,43638350,43657184,43682584,43705611,43729154,43752622,43774223,43798275,43820255,43842692,43865011,43885764,43908684,43929688,43951188,43972663,43992660,44014768,44035012,44055669,44076386,44095641,44116859,44136356,44156235,44176173,44194636,44219288,44241883,44264834,44287749,44308986,44332331,44353890,44375807,44397632,44418014,44440340,44461042,44482082,44503097,44522725,44544211,44564164,44584424,44604718,44623628,44644340,44663523,44682952,44702487,44720629,44753119,44781230,44810203,44839524,44865198,44895579,44922178,44949459,44977142,45001584,45030056,45055279,45080979,45107026,45130333,45156933,45180832,45205145,45229566,45251787,45276688,45299390,45322377,45345536,45366844,45398195,45425310,45453436,45481675,45506553,45535980,45561755,45588255,45614978,45638699,45666329,45690805,45715910,45741142,45763831,45789756,45813024,45836758,45860555,45882265,45906599,45928765,45951277,45973920,45994799,46025063,46051322,46078580,46105870,46129966,46158473,46183392,46209203,46235086,46258127,46284992,46308762,46333206,46357699,46379779,46405062,46427732,46450947,46474162,46495363,46519155,46540829,46562880,46585029,46605449,46634581,46660000,46686344,46712786,46736169,46763714,46787904,46812845,46837954,46860364,46886366,46909470,46933267,46957086,46978609,47003223,47025330,47047925,47070609,47091288,47114547,47135752,47157282,47179009,47198975,47227091,47251811,47277362,47303016,47325865,47352475,47375973,47400309,47424665,47446554,47471786,47494306,47517457,47540665,47561735,47585683,47607275,47629374,47651560,47671839,47694523,47715277,47736399,47757664,47777248,47804415,47828438,47853319,47878185,47900480,47926219,47949101,47972770,47996452,48017897,48042360,48064291,48086921,48109519,48130154,48153464,48174557,48196185,48217881,48237785,48259994,48280320,48300973,48321777,48340949,48367303,48390757,48414907,48439062,48460940,48485885,48508219,48531326,48554367,48575385,48599165,48620603,48642683,48664754,48684983,48707710,48728367,48749533,48770728,48790253,48811948,48831839,48852121,48872512,48891281,48916853,48939775,48963397,48986906,49008406,49032628,49054519,49077066,49099506,49120186,49143357,49164387,49186020,49207579,49227508,49249693,49269961,49290701,49311447,49330650,49351972,49371510,49391361,49411342,49429749,49454521,49477019,49499983,49522866,49544003,49567529,49588966,49610986,49632908,49653214,49675759,49696407,49717565,49738662,49758231,49779874,49799805,49820105,49840417,49859258,49880068,49899225,49918766,49938344,49956416,49980424,50002516,50024980,50047354,50068106,50090931,50112022,50133523,50154968,50174919,50196835,50217183,50237853,50258482,50277769,50298870,50318465,50338342,50358261,50376753,50397107,50415932,50435003,50454175,50471934,50503290,50530592,50558620,50587064,50612052,50641400,50667322,50693710,50720565,50744445,50771929,50796534,50821460,50846693,50869439,50895111,50918353,50941960,50965705,50987429,51011602,51033806,51056218,51078779,51099607,51129928,51156337,51183546,51210970,51235216,51263701,51288806,51314549,51340524,51363750,51390485,51414346,51438739,51463245,51485421,51510469,51533174,51556219,51579371,51600619,51624249,51645976,51667975,51690043,51710497,51739783,51765345,51791780,51818332,51841877,51869520,51893848,51918941,51944119,51966703,51992736,52015986,52039774,52063593,52085255,52109679,52131843,52154450,52177047,52197819,52221005,52242270,52263852,52285487,52305518,52333768,52358575,52384135,52409847,52432732,52459455,52483055,52507369,52531805,52553782,52579049,52601669,52624859,52648055,52669180,52692982,52714626,52736651,52758753,52779054,52801708,52822511,52843610,52864835,52884417,52911730,52935820,52960685,52985650,53008002,53033890,53056859,53080592,53104370,53125847,53150389,53172444,53195031,53217688,53238405,53261645,53282817,53304435,53326051,53345986,53368182,53388544,53409222,53430047,53449198,53475652,53499035,53523290,53547520,53569397,53594504,53616885,53639988,53663127,53684177,53708030,53729537,53751678,53773792,53794086,53816790,53837483,53858640,53879821,53899332,53921057,53941023,53961309,53981698,54000471,54026145,54048970,54072566,54096139,54117567,54141910,54163776,54186362,54208889,54229534,54252755,54273807,54295436,54317032,54336960,54359129,54379417,54400178,54420925,54440074,54461344,54480896,54500710,54520684,54539065,54563968,54586292,54609349,54632271,54653321,54677040,54698464,54720463,54742447,54762796,54785441,54806063,54827266,54848380,54867984,54889707,54909588,54929901,54950237,54969042,54989868,55009027,55028532,55048108,55066115,55090276,55112160,55134575,55156957,55177648,55200661,55221685,55243305,55264771,55284761,55306840,55327074,55347855,55368528,55387782,55409007,55428507,55448448,55468389,55486799,55507214,55525984,55545102,55564253,55581915,55605330,55626898,55648853,55670710,55691089,55713457,55734114,55755188,55776204,55795845,55817361,55837308,55857618,55877892,55896814,55917530,55936710,55956202,55975719,55993821,56013825,56032267,56050996,56069759,56087100,56117391,56143982,56171131,56198735,56223092,56251511,56276797,56302329,56328409,56351665,56378242,56402222,56426335,56450858,56473056,56497910,56520629,56543563,56566720,56587992,56611498,56633206,56655039,56677136,56697604,56726975,56752705,56779099,56805788,56829445,56857046,56881564,56906560,56931816,56954471,56980372,57003723,57027322,57051120,57072818,57097093,57119319,57141697,57164317,57185152,57208128,57229378,57250815,57272438,57292496,57320919,57345853,57371560,57397378,57420361,57447218,57471041,57495376,57519908,57542029,57567258,57589988,57613097,57636293,57657469,57681201,57702919,57724912,57747062,57767453,57789981,57810838,57831826,57853049,57872728,57900221,57924413,57949272,57974333,57996697,58022684,58045821,58069500,58093374,58114926,58139438,58161603,58184122,58206760,58227468,58250645,58271876,58293305,58314974,58334967,58357049,58377485,58398061,58418880,58438097,58464721,58488211,58512481,58536824,58558706,58583926,58606465,58629536,58652771,58673870,58697765,58719438,58741443,58763572,58783867,58806511,58827276,58848369,58869604,58889151,58910809,58930849,58951013,58971444,58990253,59016074,59038906,59062566,59086212,59107613,59132084,59154048,59176596,59199242,59219899,59243165,59264305,59285892,59307525,59327409,59349592,59369896,59390528,59411329,59430529,59451777,59471383,59491178,59511230,59529673,59554742,59577021,59600127,59623106,59644141,59667952,59689385,59711465,59733540,59753844,59776593,59797292,59818393,59839577,59859126,59880807,59900700,59920926,59941316,59960092,59980937,60000125,60019514,60039175,60057199,60081547,60103325,60125860,60148289,60168991,60192192,60213177,60234739,60256282,60276243,60298481,60318761,60339505,60360233,60379431,60400669,60420168,60440023,60459991,60478378,60498833,60517642,60536715,60555962,60573660,60597272,60618662,60640663,60662527,60682884,60705453,60726019,60747191,60768270,60787876,60809582,60829489,60849776,60870072,60888926,60909709,60928836,60948322,60967883,60985975,61006032,61024401,61043079,61061932,61079255,61102173,61123220,61144724,61166147,61186172,61208148,61228440,61249084,61269701,61288972,61310110,61329701,61349578,61369459,61387988,61408344,61427101,61446206,61465338,61483093,61502707,61520709,61539100,61557500,61574510};int f(int x){    int ans = 0;    while(x){        ans += x % 10;        x /= 10;    }    return ans;}int cnt = 0;int main(void){//    freopen("out.txt","w",stdout);//    int cnt=0;//    printf("{0");//    for(int i=1; i<=1000000000; i++){//        if(i%f(i)==0)//            cnt++;//        if(i%BASE==0){//            printf(",%d",cnt);//        }//    }//    printf("}");    int t, l, r, cs=1;    scanf("%d",&t);    while(t--){        scanf("%d%d",&l,&r);        int cnt=a[r/BASE]-a[(l-1)/BASE];        for(int i=r/BASE*BASE+1; i<=r; i++){            if(i%f(i)) continue;            cnt++;        }        for(int i=max((l-1)/BASE*BASE+1,1); i<l; i++){            if(i%f(i)) continue;            cnt--;        }        printf("Case %d: %d\n",cs++,cnt);    }    return 0;}

0 0
原创粉丝点击