Submission #499446

#TimeUsernameProblemLanguageResultExecution timeMemory
499446andrei_boacaPresent (RMI21_present)C++17
100 / 100
72 ms368 KiB
#include <bits/stdc++.h> using namespace std; /*ifstream fin("present.in"); ofstream fout("present.out");*/ typedef long long ll; unordered_map<ll,ll> D,X; vector<ll> mem= { 2, 33751134, 75992766, 116437886, 170615022, 230739950, 290855382, 354085694, 432245150, 531108766, 568870846, 612293630, 651920702, 705855230, 765147006, 826166782, 889429502, 965887870, 1063269118, 1145670558, 1233666430, 1357252318, 1505105918, 1644323134, 1726914174, 1843922302, 1973754878, 2150009966, 2185705342, 2227254454, 2272958142, 2325220898, 2386308846, 2447666654, 2512313086, 2591772094, 2686090078, 2721489342, 2762873582, 2807207614, 2860812970, 2921068222, 2982805942, 3046299326, 3125530302, 3223828702, 3299634926, 3397945710, 3523766646, 3685627646, 3802412270, 3892963758, 4007964398, 4140023166, 4301802902, 4353035646, 4402669774, 4468565822, 4543038414, 4623235902, 4703718326, 4812659006, 4870252470, 4918603694, 4979177630, 5051795294, 5131294166, 5208638142, 5311824478, 5417085614, 5531670398, 5687199422, 5905126910, 5994130918, 6130049998, 6292112254, 6454260062, 6511693982, 6557657406, 6627134346, 6711354582, 6783327574, 6864353278, 6981069502, 7025420990, 7080077798, 7139987262, 7216432302, 7290677566, 7371381110, 7479904094, 7587832526, 7711780334, 7862048606, 8061939046, 8162263726, 8306527614, 8474813918, 8619461022, 8685561662, 8760789726, 8850582366, 8948025534, 9071651774, 9161177470, 9228085982, 9303638654, 9395527774, 9492507006, 9615980990, 9744054878, 9895087582, 10114293502, 10281167582, 10433343198, 10653122046, 10775453182, 10842557406, 10919444350, 11009632446, 11110679294, 11237120702, 11316926014, 11384146014, 11462682494, 11551709982, 11653816702, 11782646462, 11908959614, 12069510142, 12295699198, 12446854142, 12608136574, 12833418238, 12952498558, 13032337086, 13145566046, 13265349054, 13423661822, 13499446462, 13593226622, 13701644734, 13834099262, 13993034110, 14170212222, 14437379454, 14630293886, 14842274238, 15057807710, 15141962590, 15242871390, 15364705790, 15504894910, 15611934846, 15704042206, 15804196030, 15919573438, 16073691518, 16240765662, 16452625150, 16710233790, 16884935870, 17176862206, 17215603902, 17258585214, 17303254270, 17360424366, 17422200062, 17486410110, 17551614126, 17639550974, 17722977470, 17763029150, 17804494206, 17855263998, 17918593566, 17977890046, 18041337086, 18106586110, 18198168830, 18284289534, 18367885054, 18485835774, 18615395710, 18795470590, 18872432350, 18979531518, 19104196094, 19268671742, 19350923646, 19399050174, 19437364094, 19491981694, 19553127422, 19614720766, 19680465278, 19760056062, 19861793534, 19899620350, 19942681150, 19987061886, 20044608382, 20106082558, 20170567486, 20235504318, 20323087870, 20412543486, 20493638654, 20607293182, 20737611262, 20900760318, 21007126270, 21091191678, 21218992574, 21358909438, 21489286270, 21548105214, 21602797438, 21679057598, 21752232318, 21825864446, 21925471230, 22021377790, 22080210238, 22125879710, 22200563198, 22281659710, 22356124990, 22448014078, 22557785854, 22658409534, 22807219710, 22975048702, 23137196030, 23253420414, 23412869118, 23622733278, 23667688958, 23723083646, 23786464190, 23862816510, 23939034622, 24026577278, 24135755582, 24197661310, 24247789054, 24308195518, 24387400574, 24466080254, 24542864894, 24655073278, 24765866942, 24880733182, 25040142526, 25239984382, 25338697214, 25480963454, 25648845566, 25801412542, 25870863038, 25950304830, 26042674942, 26147844990, 26280619518, 26359292670, 26429274366, 26516541822, 26609197310, 26720422654, 26854607806, 26988500990, 27175525374, 27394322174, 27529326014, 27718002430, 27926620094, 27994676734, 28068039678, 28155452158, 28261305758, 28387309310, 28481882494, 28550909310, 28631286398, 28723988862, 28826709502, 28958476926, 29086203006, 29247803134, 29474647422, 29628945918, 29796393150, 30021971966, 30135226750, 30224783742, 30339128190, 30471966590, 30612794558, 30702351102, 30806055678, 30921016190, 31072465278, 31222825854, 31422041598, 31691472382, 31877409214, 32122657790, 32274015230, 32358038270, 32474054142, 32598559742, 32754351614, 32834130814, 32938511230, 33053451774, 33194456830, 33358302590, 33548930046, 33827613374, 33993340414, 34234159870, 34402271606, 34478853054, 34582463214, 34707458494, 34874653118, 34962511358, 35040669494, 35148836462, 35279374270, 35455318390, 35635388158, 35933572862, 36111657966, 36366642942, 36550183662, 36627940286, 36731348926, 36855955702, 37023919102, 37111359990, 37189024734, 37298029038, 37428102078, 37606162174, 37784923118, 38086380782, 38261129790, 38518738430, 38710685566, 38816918426, 38960688062, 39143581630, 39263897838, 39372220086, 39524069310, 39719610302, 39938236654, 40287632894, 40520104958, 40822902270, 40917855726, 41050403774, 41214340030, 41377300718, 41477198782, 41613658878, 41784813822, 41989319798, 42304642046, 42565335038, 42924148670, 43059326118, 43208355822, 43426000622, 43572662510, 43716221886, 43917735870, 44168294654, 44569395438, 44848926462, 45149203902, 45282271850, 45464968958, 45668224238, 45794132462, 45966495678, 46205374446, 46506577134, 46850674414, 47247085038, 47399939566, 47621172158, 47850034046, 48024954094, 48289672126, 48651648510, 49066618302, 49444062010, 49619601390, 49873373918, 50050387454, 50257934778, 50545601774, 51007564014, 51384454078, 51596235438, 51678664638, 51788582526, 51921871030, 52086073006, 52163216366, 52258907070, 52380885678, 52531704766, 52702421494, 52924128502, 53200968182, 53396277742, 53692999478, 53768459710, 53863457590, 53981362614, 54130618302, 54261904046, 54338366910, 54445736894, 54572941814, 54744786878, 54909351806, 55172541678, 55404840430, 55639396094, 55874078974, 55975813870, 56116340214, 56305636286, 56439490038, 56547708142, 56697474558, 56896890814, 57116481278, 57466162550, 57696982910, 58004025846, 58101623790, 58242279918, 58414602718, 58565757422, 58669303742, 58821341118, 59005055934, 59222187518, 59576012286, 59802771198, 60141950718, 60272835038, 60443280318, 60675305198, 60803292094, 60971738046, 61212490238, 61500870398, 61860761342, 62256712366, 62394081214, 62555272958, 62790283198, 62924798846, 63084571102, 63316175806, 63586260734, 63965683454, 64309579518, 64541351678, 64760769470, 65004898238, 65180421070, 65442730942, 65786269182, 66215685870, 66616062910, 66792429502, 67054476254, 67240963966, 67454373822, 67755254254, 68216889582, 68623310590, 68763799278, 68829854838, 68958882782, 69056540118, 69164751518, 69283356118, 69346253630, 69459326622, 69563958590, 69657032126, 69829104510, 70066200054, 70340193782, 70542701294, 70837897086, 70916968894, 70982863086, 71118498750, 71208627702, 71338284926, 71439075774, 71504939966, 71615173566, 71718740342, 71815874358, 71992005230, 72225212382, 72500122870, 72727007102, 73016228982, 73090357366, 73217673782, 73330360190, 73451618174, 73587794878, 73665898742, 73826521054, 73919053790, 74094284022, 74369411574, 74671284094, 74964996062, 75195170782, 75272718270, 75434826230, 75515486142, 75698942454, 75771964214, 75882540990, 76010927550, 76116152286, 76322683358, 76619882238, 76920987614, 77267632094, 77391994478, 77569996526, 77713902302, 77890016702, 78017873854, 78187448766, 78400697310, 78731284446, 79090333422, 79467310014, 79569750974, 79746506718, 79930986462, 80067402206, 80216211054, 80370376638, 80610426846, 81010761694, 81347919614, 81650560958, 81841258366, 82009554910, 82210728926, 82410892254, 82578902974, 82955913694, 83385876222, 83781967838, 83953647486, 84124757950, 84331893374, 84507590622, 84684070846, 85028397022, 85461367262, 85904384990, 85971299774, 86043994934, 86177974206, 86267551710, 86436325854, 86502457278, 86567985086, 86708937206, 86785988574, 86939694046, 87104405374, 87363534718, 87609457262, 87860947422, 88074311646, 88140480382, 88254791390, 88360855486, 88458543070, 88598209014, 88665051102, 88766285550, 88887257022, 88973906422, 89152028542, 89390787830, 89666420606, 89869483998, 90163150590, 90267002774, 90378354622, 90509095414, 90627588062, 90769082166, 90847666110, 91009049054, 91104938718, 91282909662, 91572629246, 91875573502, 92154024926, 92381402358, 92466749374, 92621121502, 92717547262, 92886417374, 92961289182, 93110558686, 93219770302, 93358849918, 93596778366, 93952928222, 94226284414, 94501565406, 94615664750, 94798217150, 94999567070, 95114484702, 95297355742, 95450332126, 95728877166, 96136489470, 96475610878, 96710135742, 96867366782, 97017946046, 97213954526, 97343195070, 97517576158, 97739610078, 98075770846, 98451118846, 98806497246, 98986283998, 99161558974, 99371139006, 99566661566, 99737685982, 100128325502, 100539269086, 100955404766, 101134015198, 101309333438, 101519245182, 101714595774, 101885726654, 102276245982, 102687429598, 103102259070, 103244242814, 103453286334, 103666296766, 103845429182, 104057169590, 104461729534, 104950266878, 105285613502, 105466372918, 105677146878, 105846448062, 106048976830, 106309533566, 106777345790, 107220850166, 107488048374, 107733106174, 107980558270, 108209773566, 108501073406, 109077167614, 109564372414, 109793519550, 110059137682, 110220901374, 110458591734, 110939848446, 111517892350, 111846992830, 112208843450, 112451567550, 112835247998, 113548836606, 113942101950, 114281772990, 114534673342, 114906431230, 115553288062, 116077895614, 116486569918, 116804364222, 117378187006, 118151675838, 118477946366, 118819268542, 119254499198, 120099634942, 120362231742, 120572239806, 120810321854, 120947538670, 121169718710, 121506234110, 121985979630, 122442114230, 122595966910, 122804125630, 123017240750, 123217792438, 123459919806, 123886436094, 124372319998, 124663669694, 124905357246, 125161459646, 125395189694, 125699989374, 126271749886, 126749412286, 126981361598, 127247026110, 127443025854, 127687733182, 128213647102, 128849280958, 129096372158, 129427860142, 129703329726, 130206793470, 130965208830, 131236540350, 131570212798, 131845463998, 132341464830, 133077892862, 133446164414, 133784682430, 134186270462, 134999916414, 135496097726, 135871434686, 136205172478, 136946761470, 137450891198, 137491562366, 137532364126, 137581736894, 137642067230, 137703851966, 137762885374, 137826740606, 137917329342, 137986836790, 138026741694, 138068273374, 138117233534, 138177855358, 138237992126, 138296374782, 138361266686, 138451855230, 138535644382, 138618538478, 138729658366, 138861273982, 139049697390, 139125290206, 139218468606, 139343418238, 139495341822, 139601741246, 139647847214, 139687005950, 139733860574, 139795051390, 139858398974, 139922716606, 139989249070, 140073389950, 140137730526, 140182775742, 140221918654, 140269795262, 140330620350, 140393563574, 140458877822, 140522860414, 140607515422, 140694441086, 140778211822, 140895309758, 141025607166, 141203034046, 141279052766, 141383466750, 141508636094, 141673154046, 141762502526, 141813104574, 141873047486, 141944145854, 142016133598, 142094857566, 142197099450, 142281753054, 142339174334, 142384867262, 142453350270, 142537689022, 142610925790, 142689718206, 142810317790, 142904935790, 143044644798, 143212480446, 143383117566, 143491476446, 143647280190, 143847997182, 143919415166, 143966904190, 144028280798, 144099750846, 144179625854, 144256581374, 144360669054, 144434931646, 144492077534, 144548460830, 144620735102, 144692973438, 144766493790, 144859621118, 144967797230, 145069382014, 145224630014, 145396141950, 145555957630, 145666412414, 145828970366, 146030673854, 146096260574, 146164155166, 146240898142, 146332999422, 146442772414, 146569891774, 146635109982, 146703815230, 146782034654, 146876843710, 146986775166, 147116928958, 147249563870, 147438448510, 147654318462, 147786735230, 147975532414, 148184899294, 148248869310, 148319517470, 148397897598, 148495187838, 148606614526, 148723403902, 148789350366, 148858686430, 148941225726, 149041569662, 149151789566, 149281848542, 149418940158, 149603565438, 149819240414, 149956463662, 150141189886, 150339170238, 150426185598, 150527805918, 150637494014, 150777996670, 150896644030, 150980600798, 151080966590, 151204864702, 151346962366, 151508275070, 151729503742, 151977183166, 152153425886, 152429494142, 152540827614, 152624083454, 152740491134, 152861031934, 153012341694, 153088407934, 153185116030, 153293766526, 153426106814, 153587666878, 153763759070, 154037984766, 154222460670, 154443341694, 154631966142, 154678618558, 154718043646, 154766688398, 154830204190, 154893560030, 154959867774, 155028914110, 155122805022, 155178513630, 155227153518, 155265401326, 155319601118, 155380506366, 155442233214, 155508171998, 155587231486, 155688566654, 155768078574, 155861290878, 155986607870, 156138983294, 156270076798, 156359910270, 156476147326, 156607555838, 156772087006, 156811710206, 156852874686, 156903893950, 156967699758, 157026376126, 157089624414, 157153681150, 157246271358, 157316288750, 157362815470, 157402279390, 157450930910, 157514478526, 157577794782, 157644131390, 157712927454, 157807045678, 157893000190, 157981288030, 158109141230, 158243114878, 158394658174, 158478995198, 158591527262, 158722510046, 158903369214, 158956717870, 159010719086, 159072661438, 159151333246, 159228045502, 159313428350, 159422562174, 159486984062, 159535237598, 159597720510, 159673574366, 159754032254, 159831762686, 159938445182, 160054978526, 160164915070, 160327411646, 160529085662, 160625803758, 160765822910, 160933910782, 161076615102, 161135415262, 161192234878, 161267011550, 161339501918, 161414657374, 161516994046, 161608777662, 161667584958, 161713666942, 161791392766, 161869541310, 161943406814, 162036585406, 162146071422, 162248344046, 162403641534, 162571816830, 162731352558, 162844011454, 163007812478, 163210100606, 163278178270, 163347894238, 163431586014, 163534809598, 163648872190, 163761188766, 163830054110, 163907264446, 163995986558, 164098887550, 164226587582, 164358873566, 164507212798, 164721772542, 164897866206, 165049622014, 165268196542, 165398554046, 165466727294, 165556551422, 165641415614, 165755404158, 165893300958, 165960987582, 166029669310, 166112159710, 166211915646, 166327929790, 166459506558, 166599483134, 166785007102, 167001252734, 167143067070, 167329966334, 167524466174, 167613164478, 167716539102, 167842967486, 167986768830, 168099404222, 168185196478, 168296778718, 168422685054, 168586184670, 168754527998, 168994328446, 169213595518, 169418342142, 169662606782, 169752133502, 169856153470, 169971638142, 170122389374, 170232120286, 170324574078, 170430463742, 170557736830, 170719346174, 170874481374, 171108466430, 171339956094, 171538687870, 171805149422, 171878449582, 171967714686, 172079314686, 172217327358, 172359321534, 172437237422, 172534692862, 172650210814, 172806809342, 172973476606, 173195929854, 173468455678, 173661522814, 173953409182, 174026294206, 174116221166, 174227798174, 174367220990, 174508348350, 174585419198, 174684394142, 174798791166, 174955958014, 175121810606, 175347908094, 175618155262, 175812983806, 176102580278, 176198659438, 176322917310, 176475787006, 176651614078, 176746419966, 176878962622, 177042955262, 177249668862, 177537296638, 177818776958, 178142652158, 178312775294, 178419509934, 178568035838, 178761125630, 178858739646, 178981759934, 179126784766, 179328857470, 179560983486, 179898527678, 180156431870, 180433866494, 180566013310, 180742307326, 180952112894, 181077093166, 181244165630, 181481530110, 181773034494, 182127960830, 182528278014, 182648522494, 182801960830, 183018900478, 183165457342, 183309053822, 183512813310, 183765646846, 184163216638, 184452054526, 184757677502, 184934825726, 185206324734, 185364311806, 185577527742, 185875369854, 186336673278, 186763046910, 186965863870, 187171498494, 187410859966, 187580146622, 187831680510, 188159118846, 188600283134, 188992720126, 189073263070, 189172858622, 189292046078, 189451839230, 189562589118, 189645611966, 189755163950, 189886549758, 190061819006, 190234705662, 190525230846, 190720133614, 190969789950, 191168859310, 191248230638, 191358839006, 191486914782, 191663563006, 191739023022, 191829292222, 191943651070, 192086682046, 192267077886, 192467205630, 192765097982, 192946422718, 193251081726, 193356746494, 193483417534, 193638865918, 193823190126, 193921095550, 194054680238, 194220198590, 194428542078, 194715514878, 194998058750, 195320401662, 195494026430, 195606112190, 195761492126, 195960439774, 196055998334, 196177670014, 196336942590, 196545787390, 196805574142, 197114275582, 197402389950, 197644665566, 197788342142, 197991325182, 198176483070, 198317970430, 198517546750, 198774353918, 199179526910, 199455145470, 199768990654, 199911045630, 200096628478, 200299159422, 200438066622, 200625082110, 200875319038, 201230765822, 201542438654, 201903030142, 202076234686, 202337140478, 202520448958, 202738657726, 203038403518, 203490922366, 203886907134, 204132765630, 204350062078, 204593643262, 204774426558, 205035650558, 205388840446, 205814785022, 206170171678, 206235399390, 206323891966, 206441965502, 206532558590, 206697127806, 206762495326, 206828469246, 206965893566, 207043323838, 207178973054, 207343525630, 207603127678, 207850964862, 208109311198, 208321263198, 208386727870, 208483803006, 208603242238, 208687718270, 208848251102, 208913672062, 208984269822, 209118633918, 209196416894, 209351311102, 209516999550, 209780768254, 210017888766, 210269028094, 210489465086, 210567663486, 210728091518, 210819596158, 210992038198, 211066176606, 211193483134, 211306219710, 211427551998, 211631095550, 211936978942, 212242284286, 212600899198, 212673891678, 212783762302, 212912766718, 213017774878, 213171332030, 213248644222, 213410718814, 213491679166, 213675095262, 213948388830, 214247374334, 214532488190, 214784174526, 214896892606, 215078788606, 215286446014, 215382777790, 215558160254, 215706066814, 215971904382, 216386843518, 216719892350, 216963773662, 217103216574, 217257384318, 217449533726, 217563709182, 217738247678, 217929775038, 218243415934, 218593244382, 219010629374, 219155957630, 219359739774, 219584076062, 219719229374, 219920469950, 220170198526, 220654301054, 221044407806, 221283604862, 221486012350, 221695868798, 221837344638, 222039641018, 222270324478, 222676844286, 223138479870, 223373957854, 223440610878, 223554281214, 223664026558, 223767830462, 223897501438, 223963905918, 224079521598, 224186027582, 224282287998, 224458505982, 224693671134, 224967669214, 225195179774, 225487160414, 225554008286, 225622628062, 225760026494, 225839235006, 225996367614, 226073231230, 226139611006, 226289884158, 226368030942, 226503480254, 226668846078, 226928891006, 227178211838, 227436857822, 227661610942, 227743631550, 227906666366, 227995697086, 228171977950, 228247159902, 228378272446, 228505700574, 228621384702, 228836417022, 229176786814, 229460716158, 229784620990, 229859479486, 229992254238, 230117435006, 230251186974, 230364156798, 230458511102, 230602729406, 230700787582, 230902158718, 231195093470, 231480180606, 231777238526, 232000338526, 232154947518, 232307736318, 232503619454, 232633091006, 232806731646, 233027469054, 233361129214, 233740216958, 234089810366, 234208140798, 234387226494, 234590906110, 234705892222, 234885967806, 235049123582, 235326444542, 235729092350, 236068912894, 236313927614, 236525663102, 236738488062, 236877774718, 237096937406, 237339287294, 237802421246, 238210711038, 238462982078, 238673301374, 238886738622, 239026110334, 239244574590, 239487131390, 239951804414, 240359071486, 240598927550, 240800378806, 241055895478, 241168158462, 241387486974, 241665785342, 242171308286, 242669317886, 242781300478, 243004025278, 243233223678, 243375491774, 243581112062, 243926032382, 244402124006, 244855350334, 245084169982, 245350212254, 245505776638, 245745548798, 246229040638, 246806816766, 247075811198, 247329357310, 247569017342, 247800726526, 248102005118, 248673410814, 249171492350, 249448595198, 249739967998, 250030804734, 250663532542, 251289324030, 251551691518, 251860054782, 252136483262, 252665478654, 253406564094, 253715087102, 254049206142, 254445812734, 255259835390, 255740952446, 256122227642, 256435322366, 257162690302, 257739087614, 257905573630, 258111853502, 258313214462, 258516076222, 258776765566, 259236199422, 259690561022, 259942585278, 260152600318, 260393157566, 260525327134, 260747442334, 261059869694, 261562301950, 262030491390, 262255344638, 262518602750, 262697826174, 262937340830, 263425817598, 264017411070, 264275888894, 264519794430, 264758107326, 265001418238, 265328107262, 265932021502, 266380932030, 266684693502, 266972248638, 267348604926, 268001629182, 268519382206, 268819156734, 269114162174, 269483289342, 270133427710, 270687280894, 271089379070, 271423037182, 272001662462, 272773861118, 273108082430, 273474153214, 273922211326, 274838452222 }; void precalc() { for(int i=1;i<=40;i++) for(int j=1;j<=40;j++) if(i>j) { int k=__gcd(i,j); ll I=(1LL<<i); ll J=(1LL<<j); ll K=(1LL<<k); if(J==K) D[I]|=K; X[I|K]|=J; X[J|K]|=I; } } struct gcdSet { vector<ll> ST; ll val; int ord; gcdSet() { val=1LL<<1; ST.push_back(val); ord=1; } void nxt() { ll aux=val+2LL; ll bit=(aux&(-aux)); while(ST.size()&&ST.back()<bit) { val-=ST.back(); ST.pop_back(); } ll di=D[bit]-(D[bit]&val); ll st=bit; while(di) { ll divi=(di&(-di)); if(X[divi|bit]&val) st|=divi; di-=divi; } ST.push_back(st); val|=st; ord++; } }; gcdSet gSet(int i) { gcdSet ret; ll aux=mem[i]; vector<ll> St; ll Val=0LL; int Ord=1000000*i+1; for(ll bit=1LL<<37; bit>1LL; bit>>=1) if(aux&bit) { ll st=bit; ll di=D[bit]-(D[bit]&Val); while(di) { ll diBit=di&(-di); if(X[bit|diBit]&Val) st|=diBit; di-=diBit; } St.push_back(st); Val|=st; aux^=st; } ret.val=Val; ret.ST=St; ret.ord=Ord; return ret; } void solve() { ll k; cin>>k; if(k==0) { cout<<0<<'\n'; return; } ll poz=k/1000000; gcdSet A=gSet(poz); while(A.ord<k) A.nxt(); ll mask=A.val; vector<int> vals; for(int bit=1;bit<=40;bit++) if((mask>>bit)&1) vals.push_back(bit); cout<<vals.size()<<' '; for(auto i:vals) cout<<i<<' '; cout<<'\n'; } int main() { precalc(); ll t; cin>>t; while(t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...