链接:https://www.nowcoder.com/acm/contest/135/D
来源:牛客网
输入数据共一行,一个正整数n,意义如“问题描述”。
输出一行描述答案:
一个正整数k,表示S的末尾有k个0
示例1
复制
10
复制
7
之前学习过分块,刚好用这道题试一下。
不过分的有点多了,分了1000个块,其实10个块就能过。
代码:
#include
const int maxn=1e8+10;
#define ll long long
ll kuai[1110]={0,1249668749,4999296873,11248887498,19998459374,31248093749,44997693748,61247253122,79996812499,101246418748,124995984373,151245521873,179995062498,211244637498,244994174997,281243687498,319993209373,361242753122,404992262498,451241753122,499991296874,551240912498,604990499998,661240059373,719989637498,781239218749,844988787498,911238315622,979987871873,1051237434373,1124986968748,1201236468747,1279986003122,1361235543748,1444985049997,1531234515622,1619984037498,1711233549997,1804983024997,1901232462496,1999982062499,2101231646873,2204981190622,2311230703124,2419980293748,2531229843748,2644979359372,2761228859373,2879978418748,3001227940622,3124977421873,3251226912498,3379976440622,3511225931247,3644975393747,3781224859373,3919974359372,4061223818746,4204973259372,4351222746873,4499972312498,4651221849998,4804971362497,4961220887498,5119970424997,5281219937498,5444969421872,5611218924997,5779968434373,5951217924997,6124967374997,6301216859372,6479966346872,6661215806247,6844965228121,7031214687498,7219964156247,7411213584371,7604962974996,7801212512498,7999962046873,8201211546872,8404961006246,8611210543748,8819960049997,9031209515622,9244958959373,9461208471872,9679957946872,9901207384371,10124956812498,10351206296872,10579955740621,10811205149997,11044954565622,11281204015622,11519953431246,11761202818746,12004952281249,12251201903123,12499951484374,12751201053123,13004950624998,13261200215623,13519949778123,13781199312498,14044948865623,14311198424997,14579947965623,14851197471872,15124946999998,15401196537498,15679946049997,15961195524997,16244945034372,16531194546873,16819944031247,17111193474996,17404943046874,17701192637498,17999942187498,18301191703122,18604941281248,18911190840623,19219940362497,19531189843749,19844939412498,20161188940622,20479938431247,20801187903123,21124937437498,21451186937497,21779936396871,22111185856248,22444935362497,22781184828122,23119934265622,23461183734373,23804933309373,24151182846872,24499932359373,24851181881248,25204931424997,25561180934373,25919930424997,26281179921873,26644929437497,27011178924997,27379928384372,27751177862497,28124927343748,28501176812497,28879926240621,29261175696872,29644925159372,30031174593747,30419923993746,30811173503122,31204923043748,31601172549997,31999922015622,32401171537498,32804921049997,33211170524997,33619919962496,34031169468748,34444918953122,34861168396871,35279917809373,35701167299997,36124916749997,36551166165621,36979915565622,37411165024997,37844914446871,38281163828122,38719913240623,39161162768747,39604912259372,40051161721872,40499911187498,40951160687497,41404910146871,41861159587497,42319909034372,42781158499997,43244907937497,43711157349996,44179906774997,44651156212496,45124905624997,45601155009371,46079904412496,46561153821872,47044903212496,47531152562496,48019902084373,48511151671873,49004901231248,49501150753122,49999900312499,50501149881248,51004899409372,51511148899997,52019898449998,52531147984373,53044897484372,53561146943746,54079896481248,54601145987497,55124895453122,55651144896873,56179894409372,56711143884372,57244893321871,57781142765624,58319892349998,58861141893747,59404891403123,59951140918748,60499890468748,61051139984372,61604889471872,62161138965623,62719888487497,63281137968748,63844887437497,64411136909372,64979886399997,65551135862497,66124885296872,66701134749997,67279884209371,67861133649997,68444883056246,69031132546873,69619882084373,70211131596872,70804881071872,71401130581247,71999880093748,72601129578122,73204879021871,73811128512498,74419878003122,75031127453122,75644876868746,76261126346872,76879875806247,77501125228121,78124874609373,78751124078122,79379873506246,80011122896871,80644872278123,81281121812498,81919871312497,82561120771871,83204870231248,83851119737497,84499869203122,85151118640622,85804868081247,86461117556247,87119866993746,87781116406247,88444865828122,89111115271871,89779864681247,90451114071871,91124863468747,91801112884371,92479862271871,93161111631246,93844861065622,94531110546873,95219860015622,95911109443746,96604858899997,97301108362497,97999857796872,98701107196871,99404856631246,100111106071872,100819855478121,101531104843746,102244854265622,102961103678121,103679853053121,104401102390620,105124851796872,105851101181246,106579850524995,107311099843749,108044849434373,108781098984373,109519848499997,110261097999998,111004847559373,111751097081247,112499846562498,113251096053123,114004845581247,114761095071872,115519844534372,116281093999998,117044843499997,117811092959371,118579842399997,119351091846872,120124841312497,120901090749997,121679840162496,122461089637498,123244839174997,124031088687498,124819838171872,125611087674997,126404837184373,127201086674997,127999836124997,128801085609372,129604835096872,130411084556247,131219833978121,132031083437498,132844832906247,133661082334371,134479831724996,135301081174997,136124830609372,136951080009371,137779829368745,138611078903123,139444828409372,140281077874997,141119827318748,141961076831247,142804826306247,143651075743746,144499825171873,145351074656247,146204824099996,147061073509372,147919822924997,148781072374997,149644821790621,150511071178121,151379820571872,152251069993746,153124819374997,154001068743746,154879818159372,155761067649997,156644817112497,157531066546872,158419815999997,159311065459371,160204814899997,161101064306246,161999813734372,162901063171872,163804812584371,164711061959371,165619811368746,166531060781247,167444810165621,168361059509370,169279808899997,170201058290621,171124807640621,172051056956245,172979806424997,173911055884372,174844805306246,175781054687498,176719804156247,177661053584371,178604802974996,179551052346872,180499801781247,181451051181246,182404800540620,183361049899997,184319799306246,185281048671871,186244798009371,187211047349996,188179796724996,189151046062495,190124795374996,191101044771873,192079794315622,193061043824998,194044793315622,195031042812498,196019792328122,197011041815622,198004791274997,199001040753122,199999790234373,201001039703122,202004789131246,203011038587497,204019788049997,205031037484372,206044786884371,207061036318746,208079785759372,209101035165621,210124784531246,211151034037498,212179783549997,213211033024997,214244782462496,215281031968748,216319781453122,217361030896871,218404780309373,219451029799997,220499779249997,221551028665621,222604778065622,223661027524997,224719776946871,225781026328122,226844775718747,227911025146871,228979774537496,230051023899996,231124773296873,232201022796872,233279772256246,234361021696872,235444771143747,236531020609372,237619770046872,238711019459371,239804768884372,240901018321871,241999767734372,243101017118746,244204766521871,245311015931247,246419765321871,247531014671871,248644764056246,249761013443746,250879762803121,252001012124995,253124761562498,254251011031247,255379760459371,256511009849996,257644759299997,258781008734372,259919758134371,261061007493745,262204756931247,263351006337496,264499755703121,265651005046872,266804754459371,267961003834371,269119753171870,270281002499997,271444751884371,272611001228120,273779750537496,274950999878122,276124749328122,277300998743746,278479748131246,279660997524997,280844746946871,282030996328122,283219745696871,284410995068746,285604744459371,286800993821871,287999743156246,289200992509371,290404741868745,291610991209371,292819740515620,294030989843746,295244739181246,296460988493745,297679737768745,298900987293748,300124736906249,301350986490623,302579736034372,303810985624999,305044735215623,306280984765623,307519734281247,308760983859373,310004733418748,311250982940622,312499732421874,313750981990623,315004731518747,316260981009372,317519730481248,318780980015623,320044729515622,321310978974996,322579728453124,323850978059373,325124727624998,326400977162498,327679726703123,328960976278123,330244725815622,331530975328123,332819724849998,334110974393747,335404723903123,336700973393747,337999722890623,339300972406247,340604721893747,341910971353122,343219720831247,344530970312498,345844719781247,347160969209371,348479718731248,349800968293748,351124717828123,352450967328122,353779716862497,355110966403123,356444715909372,357780965374997,359119714896873,360460964409372,361804713884372,363150963321871,364499712828123,365850962312497,367204711756246,368560961168748,369919710659372,371280960109372,372644709524996,374010958937498,375379708496873,376750958018747,378124707499998,379500956990623,380879706518747,382260956009372,383644705471872,385030954937498,386419704437497,387810953896871,389204703337497,390600952784372,391999702249997,393400951687497,394804701099996,396210950524997,397619699962496,399030949374997,400444698759371,401860948221872,403279697731248,404700947221872,406124696671872,407550946156247,408979695643747,410410945103122,411844694524996,413280943984373,414719693453122,416160942881246,417604692271871,419050941721872,420499691156247,421950940556246,423404689915620,424860939353122,426319688759371,427780938124996,429244687481249,430710937093748,432179686668748,433650936206247,435124685734374,436600935318748,438079684862497,439560934371873,441044683887498,442530933437498,444019682953122,445510932440622,447004681934373,448500931456247,449999680937498,451500930406247,453004679878122,454510929368747,456019678831247,457530928265622,459044677771873,460560927331247,462079676871873,463600926378122,465124675906248,466650925443748,468179674956247,469710924431247,471244673940622,472780923453123,474319672937497,475860922381246,477404671871873,478950921362497,480499670812497,482050920228121,483604669706247,485160919165622,486719668587496,488280917968749,489844667537498,491410917065622,492979666556247,494550916028123,496124665562498,497700915062497,499279664521871,500860913981248,502444663487497,504030912953122,505619662390622,507210911831247,508804661306247,510400910743746,511999660156247,513600909578122,515204659021871,516810908431247,518419657821871,520030907265623,521644656781247,523260906268747,524879655728122,526500905206247,528124654687498,529750904156247,531379653584371,533010903040622,534644652503122,536280901937497,537919651337496,539560900771871,541204650212497,542850899618746,544499648984371,546150898406247,547804647818746,549460897193746,551119646531245,552780896031248,554444645515622,556110894959371,557779644371873,559450893862497,561124643312497,562800892728121,564479642128122,566160891587497,567844641009371,569530890390622,571219639781247,572910889209371,574604638599996,576300887962496,577999637328122,579700886728121,581404636087495,583110885428121,584819634856248,586530884421873,588244633959373,589960883471872,591679632996873,593400882534372,595124632046873,596850881531247,598579631034372,600310880543748,602044630034372,603780879484372,605519628968747,607260878456247,609004627915622,610750877337496,612499626796873,614250876265622,616004625693746,617760875084371,619519624621873,621280874156248,623044623656247,624810873115621,626579622653123,628350872159372,630124621624997,631900871068748,633679620581247,635460870056247,637244619493746,639030868921873,640819618406247,642610867849996,644404617259372,646200866674997,647999616124997,649800865540621,651604614928121,653410864356248,655219613878122,657030863359373,658844612828122,660660862299997,662479611790622,664300861253122,666124610687497,667950860140622,669779609599996,671610859040622,673444608446871,675280857874997,677119607312497,678960856724996,680804606099996,682650855509371,684499604921872,686350854306246,688204603649995,690060853121873,691919602612497,693780852062497,695644601478121,697510850956247,699379600415622,701250849837496,703124599218748,705000848687497,706879598115621,708760847506246,710644596878122,712530846312497,714419595712496,716310845071870,718204594431247,720100843837496,721999593203121,723900842540621,725804591909372,727710841384372,729619590821871,731530840234372,733444589656247,735360839099996,737279588509372,739200837899996,741124587296872,743050836712496,744979586099996,746910835459371,748844584837496,750780834218747,752719583587496,754660832915620,756604582271871,758550831634371,760499580968746,762450830268745,764404579753122,766360829293748,768319578799997,770280828265622,772244577787498,774210827299997,776179576774997,778150826212496,780124575718748,782100825203122,784079574646871,786060824059373,788044573549997,790030822999997,792019572415621,794010821815622,796004571274997,798000820696871,799999570078122,802000819490623,804004569018747,806010818509372,808019567971872,810030817437498,812044566937497,814060816396871,816079565837497,818100815284372,820124564749997,822150814187497,824179563599996,826210813024997,828244562462496,830280811874997,832319561259371,834360810662496,836404560071872,838450809462496,840499558812496,842550808265622,844604557753122,846660807212497,848719556634371,850780806093748,852844555562497,854910804990621,856979554381246,859050803831247,861124553265622,863200802665621,865279552024995,867360801462497,869444550868746,871530800234371,873619549578122,875710798990621,877804548365621,879900797703120,881999547046873,884100796531247,886204545974996,888310795384372,890419544799997,892530794249997,894644543665621,896760793053121,898879542446872,901000791868746,903124541249997,905250790618746,907379539990621,909510789381246,911644538743746,913780788078121,915919537431246,918060786790620,920204536131246,922350785437495,924499534828122,926650784265622,928804533678121,930960783053121,933119532462496,935280781874997,937444531259371,939610780603120,941779529993747,943950779384371,946124528734371,948300778049995,950479527428121,952660776787496,954844526109370,957030775390622,959219524759371,961410774087495,963604523378120,965800772668748,967999522203123,970200771703122,972404521162496,974610770621873,976819520128122,979030769593747,981244519031247,983460768471872,985679517946872,987900767384371,990124516796872,992350766218747,994579515662496,996810765071872,999044514462496,1001280763859372,1003519513274996,1005760762662496,1008004512021871,1010250761456247,1012499510937498,1014750760406247,1017004509834371,1019260759290622,1021519508753122,1023780758187497,1026044507587496,1028310757021871,1030579506462497,1032850755868746,1035124505234371,1037400754656247,1039679504068746,1041960753443746,1044244502781245,1046530752187497,1048819501571871,1051110750915620,1053404500231248,1055700749721872,1057999499171872,1060300748587496,1062604497987497,1064910747446872,1067219496868746,1069530746249997,1071844495640622,1074160745068746,1076479494459371,1078800743821871,1081124493187497,1083450742587496,1085779491946870,1088110741287496,1090444490634371,1092780739999996,1095119489337496,1097460738649995,1099804488024997,1102150737462496,1104499486874997,1106850736259371,1109204485662496,1111560735071872,1113919484462496,1116280733812496,1118644483196871,1121010732584371,1123379481943746,1125750731265620,1128124480624997,1130500729993746,1132879479321870,1135260728612495,1137644477962496,1140030727296871,1142419476596870,1144810725856244,1147204475290622,1149600724696871,1151999474062496,1154400723406247,1156804472818746,1159210722193746,1161619471531245,1164030720859372,1166444470243746,1168860719587495,1171279468896871,1173700718212496,1176124467562496,1178550716878120,1180979466165620,1183410715459371,1185844464781245,1188280714062496,1190719463331245,1193160712734373,1195604462324998,1198050711887498,1200499461421873,1202950710974998,1205404460534372,1207860710074998,1210319459581247,1212780709109373,1215244458646873,1217710708159372,1220179457634372,1222650707143747,1225124456656248,1227600706140622,1230079455584371,1232560705074998,1235044454565622,1237530704015622,1240019453431246,1242510702999998,1245004452559373,1247500702081247,1249999451562499};
ll go(int n)
{
ll sum=0;
for(int i=5;n/i>0;i*=5)
{
sum+=n/i;
}
return sum;
}
int block=100000;
ll query(int x)
{
ll ans=kuai[x/block];
for (int i=x/block*block+1;i<=x;i++)
ans+=go(i);
return ans;
}
int main()
{
int n;
scanf("%d",&n);
printf("%lld\n",query(n));
return 0;
}