首页 > 其他分享 >ARC166E Fizz Buzz Difference

ARC166E Fizz Buzz Difference

时间:2023-10-10 09:11:47浏览次数:34  
标签:bmod 欧去 al Buzz ARC166E Difference Fizz

题面传送门

首先一个观察是随着 \(n\) 的增大,最长的区间肯定是增大的,因此可以直接把等式放缩成 \(\leq n\)。

另一个观察使为了使区间长度最大,左右端点肯定是顶着两个 \(a\) 的,不妨设其为 \(al+1\) 和 \(ar-1\)。

将 \(a,b\) 先搞成互质的,那么现在的问题是我们需要最大化区间内 \(a\) 的个数,也即最大化 \(b\) 的个数。如果 \(al+1\) 位置恰好是一个 \(b\),那么这样是最优的,而根据裴蜀定理这是一定可以取到的,所以可以用 exgcd 解出一组最大 \(r-l\) 的 \(l,r\)。

然后我们需要使 \(l\) 最小。因为 \((b-(al+1))\bmod b\) 可以看成前面空着的,因此可以列出 \(al\bmod b\geq w\) 的不等式,这个不等式可以用类欧去找到最小的 \(l\)。不想写类欧去 jiangly 那里贺了一个(

时间复杂度 \(O(T\log a)\)。

submission

标签:bmod,欧去,al,Buzz,ARC166E,Difference,Fizz
From: https://www.cnblogs.com/275307894a/p/17753713.html

相关文章

  • difference between a Client-Server and Sender-Receiver interface in Autosar
    thedifferencebetweenaClient-ServerandSender-ReceiverinterfaceinAutosarInaClient-Serverinterface,theclientrequestsaservicefromtheserverandtheserverrespondswitharesult.InaSender-Receiverinterface,thesendersendsdatatoone......
  • What's the difference between Industrial Maxon Wireless 802.11ac AP and router
    ThemaindifferencebetweenindustrialAPsandroutersistheirintendeduse.IndustrialAPsaredesignedforuseinharshenvironments,suchasfactories,warehouses,andoutdoorlocations.Theyaretypicallymoreruggedandhaveawidertemperaturerang......
  • What's the difference between Async Await and Promise in JavaScript All In One
    What'sthedifferencebetweenAsyncAwaitandPromiseinJavaScriptAllInOneAsyncvsPromisedemos(......
  • 【lc 412】Fizz buzz
    链接https://leetcode.cn/problems/fizz-buzz/description/分析没啥好分析的。。。注意他的下标是从1开始的,要把咱们自己的下标转换成虚拟下标。代码classSolution:deffizzBuzz(self,n:int):"""给你一个整数n,找出从1到n各个整数的FizzBu......
  • 【RL】L7-Temporal-difference learning
    TDlearningofstatevaluesThedata/experiencerequiredbythealgorithm:\(\left(s_0,r_1,s_1,\ldots,s_t,r_{t+1},s_{t+1},\ldots\right)\)or\(\left\{\left(s_t,r_{t+1},s_{t+1}\right)\right\}_t\)generatedfollowingthegivenpolicy......
  • difference between store procedures and functions
    Functionscan'tmodifyanythingandmusthaveatleastoneparameter.Theyalsohavetoreturnaresult.Storedproceduresdon'tneedaparameter,maymodifydatabaseobjects,anddon'thavetoreturnaresult.Storedproceduresareusedto......
  • P3519 [POI2011]ROZ-Difference
    考虑枚举最大的字母所处的位置\(i\)作为端点和最小的字母\(j\)。然后就有记录一下前缀出现次数\(cnt\),枚举一个区间。\[cnt_{i,ch_i}-cnt_{i,j}-(cnt_{i',ch_i}-cnt_{i',j})\]求这个式子最大值。显然这两个式子相似,记录一下关于\(ch_i\)的\(cnt\)前缀最小值即......
  • Wallys WIFI7 Mainboard /the difference between ipq9574 with ipq9554/DBDC.
    WIFI7MainboardSPECTheIPQ9574andIPQ9554arebothsystem-on-chip(SoC)solutionsdesignedbyQualcommfornetworkingapplications,buttheybelongtodifferentgenerationsandofferdifferentcapabilities.Herearethekeydifferencesbetweenthetwo:G......
  • What are the differences between in vivo and in vitro testing of drugs for toxic
    Intoxicologystudies,therearetwomaintypesoftestsusedtoassessthesafetyandpotentialtoxiceffectsofdrugs:invivotestsandinvitrotests.Weknowthatthetraditionalmethodofdrugtoxicologyresearchistouseanimalmodelsforinvivo......
  • Differences between SysVinit, Upstart and Systemd
    DifferencesbetweenSysVinit,UpstartandSystemdhttps://www.computernetworkingnotes.com/linux-tutorials/differences-between-sysvinit-upstart-and-systemd.html#:~:text=To%20refer%20to%20the%20initialization%20process%2C%20the%20SysVinit,%27UNIX%20System%2......