正文
增加 958 行删除 958 行
89 行未改动909192939495969798406 行未改动全部展开505506507508509510511512513167 行未改动全部展开6816826836846856866876886896906916927 行未改动7007017027037047057067077087097107117126 行未改动71972072172272372472572672714 行未改动74274374474574674774874975075153 行未改动805806807808809810811812813359 行未改动全部展开117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512468 行未改动1255125612571258125912601261126212638 行未改动1272127312741275127612771278127912808 行未改动1289129012911292129312941295129612978 行未改动130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213737 行未改动138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314244 行未改动14291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147058 行未改动15291530153115321533153415351536153712 行未改动1550155115521553155415551556155715585 行未改动15641565156615671568156915701571157234 行未改动16071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816497 行未改动16571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316844 行未改动168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917204 行未改动17251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176613 行未改动17801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181513 行未改动1829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185111 行未改动1863186418651866186718681869187018717 行未改动187918801881188218831884188518861887188818891890189118921893189411 行未改动1906190719081909191019111912191319142 行未改动1917191819191920192119221923192419257 行未改动193319341935193619371938193919401941194219431944194519461947194819491950195119521953195422 行未改动19771978197919801981198219831984198519861987198819891990199119921993199419958 行未改动20042005200620072008200920102011201210 行未改动202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205623 行未改动20802081208220832084208520862087208820892090209120927 行未改动2100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212245 行未改动21682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012 行未改动2204220522062207220822092210221122122213221422152216221722182219222022212222222346 行未改动22702271227222732274227522762277227829 行未改动2308230923102311231223132314231523164 行未改动232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239312 行未改动24062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242973 行未改动25032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326443 行未改动2648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270047 行未改动27482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290034 行未改动2935293629372938293929402941294229432944294529462947294829492950295129522 行未改动295529562957295829592960296129622963296429652966296729682969297029714 行未改动29762977297829792980298129822983298429852986298729882989299029912992299323 行未改动30173018301930203021302230233024302517 行未改动30433044304530463047304830493050305121 行未改动3073307430753076307730783079308030816 行未改动308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114103 行未改动全部展开321832193220322132223223322432253226322732284 行未改动323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432554 行未改动3260326132623263326432653266326732685 行未改动327432753276327732783279328032813282328332843285328632873288266 行未改动全部展开35553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358731 行未改动36193620362136223623362436253626362713 行未改动36413642364336443645364636473648364918 行未改动36683669367036713672367336743675367636773678367936809 行未改动3690369136923693369436953696369736986 行未改动3705370637073708370937103711371237137 行未改动372137223723372437253726372737283729155 行未改动全部展开388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390925 行未改动39353936393739383939394039413942394328 行未改动39723973397439753976397739783979398038 行未改动40194020402140224023402440254026402730 行未改动40584059406040614062406340644065406626 行未改动4093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411858 行未改动417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841997 行未改动42074208420942104211421242134214421537 行未改动4253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842796 行未改动42864287428842894290429142924293429415 行未改动431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434016 行未改动4357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434 行未改动444844494450445144524453445444554456104 行未改动全部展开45614562456345644565456645674568456988 行未改动4658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747085 行未改动47144715471647174718471947204721472247234724472547264727472847294730473147324733293 行未改动全部展开502750285029503050315032503350345035503650375038503950405041504250435044504583 行未改动512951305131513251335134513551365137513851395140514151425143100 行未改动52445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353346 行未改动53415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454252 行未改动542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754982 行未改动5501550255035504550555065507550855094 行未改动551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855392 行未改动5542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855897 行未改动5597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156323 行未改动5636563756385639564056415642564356445645564656475648564956504 行未改动56555656565756585659566056615662566313 行未改动567756785679568056815682568356845685568656875688568956905691569256932 行未改动56965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574014 行未改动57555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577810 行未改动578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745 行未改动588058815882588358845885588658875888588958905891589258935894589558966 行未改动5903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360049 行未改动60146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360442 行未改动60476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610029 行未改动613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615717 行未改动617561766177617861796180618161826183618461856186618761886189619014 行未改动62056206620762086209621062116212621380 行未改动6294629562966297629862996300630163023 行未改动63066307630863096310631163126313631463155 行未改动6321632263236324632563266327632863296330633163326333633415 行未改动6350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638418 行未改动6403640464056406640764086409641064117 行未改动64196420642164226423642464256426642764286429643064316432643364346435643619 行未改动64566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650322 行未改动6526652765286529653065316532653365342 行未改动6537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466355 行未改动664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670484 行未改动67896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568168 行未改动6825682668276828682968306831683268335 行未改动6839684068416842684368446845684668473 行未改动685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969003 行未改动690469056906690769086909691069116912691369146915691669176918691969202 行未改动6923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469553 行未改动6959696069616962696369646965696669676968696969706971697269736974697547 行未改动7023702470257026702770287029703070317032703370347035703670377038703970407041704270436 行未改动7050705170527053705470557056705770583 行未改动70627063706470657066706770687069707010 行未改动708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371548 行未改动716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972305 行未改动7236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673972 行未改动7400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769519 行未改动77157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877396 行未改动774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784512 行未改动785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079614 行未改动796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592729 行未改动全部展开89 行未改动```cppstruct Save {string path; // 文件路径int errorlevel; // 错误代码// 方法void setpt(string s); // 设置路径void read_nol(); // 以文本模式打开读取void read_bin(); // 以二进制模式打开读取406 行未改动全部展开#### 文件日志```cppstruct logger {enum error_type { error=0, info=1, warn=2, debug=3 };void reset_logger(string path); // 初始化日志文件void report(string s, error_type tp); // 记录日志void stop(); // 停止日志};167 行未改动全部展开int main() {scg(RED, BLACK);say("Hello, World!", 50);scg(GREEN, BLACK);cout << "2 + 2 = " << PLS(2, 2) << endl;return 0;}```7 行未改动file.setpt("test.txt");file.save_nol();file.save_o << "Hello, File!" << endl;file.save_stop();if (fileok("test.txt")) {cout << "File created successfully!" << endl;}return 0;}```6 行未改动cout << "PI = " << PI << endl;cout << "sqrt(2) = " << getSqrtNt(2, 0.0001) << endl;cout << "5! = " << fac(5) << endl;cout << "Is 17 prime? " << isPrime(17) << endl;return 0;}```14 行未改动此指南涵盖了jtbg.h库的主要功能,具体使用时请参考源代码中的详细实现和注释。## 七、下载[ilanzou(持续更新)](https://www.ilanzou.com/s/83wNo2Vk)[ilanzou(2.9)](https://www.ilanzou.com/s/gE2nYqIi)## 八、源码```cpp#undef _WIN32_WINNT53 行未改动#pragma GCC optimize("O0")//你可以换成指令: -O0#endif#pragma cpp_std c++11//你可以换成指令: -std=gnu++11#pragma comment(lib, "winmm.lib")//你可以换成 -lwinmm#pragma comment(lib, "wininet.lib")359 行未改动全部展开}#endif#ifdef JTBG_HASHclass MD5{private:typedef unsigned int uint32;typedef unsigned long long uint64;struct Context{uint32 state[4];uint32 count[2];unsigned char buffer[64];};static void init(Context &ctx){ctx.count[0] = ctx.count[1] = 0;ctx.state[0] = 0x67452301;ctx.state[1] = 0xefcdab89;ctx.state[2] = 0x98badcfe;ctx.state[3] = 0x10325476;}static void update(Context &ctx, const unsigned char *input, size_t length){uint32 i, index, partLen;index = (uint32)((ctx.count[0] >> 3) & 0x3F);if ((ctx.count[0] += ((uint32)length << 3)) < ((uint32)length << 3))ctx.count[1]++;ctx.count[1] += (uint32)(length >> 29);partLen = 64 - index;if (length >= partLen){memcpy(&ctx.buffer[index], input, partLen);transform(ctx.state, ctx.buffer);for (i = partLen; i + 63 < length; i += 64)transform(ctx.state, &input[i]);index = 0;}else{i = 0;}memcpy(&ctx.buffer[index], &input[i], length - i);}static void final(unsigned char digest[16], Context &ctx){unsigned char padding[64] = {0x80};unsigned char bits[8];size_t index, padLen;encode(bits, ctx.count, 8);index = (uint32)((ctx.count[0] >> 3) & 0x3f);padLen = (index < 56) ? (56 - index) : (120 - index);update(ctx, padding, padLen);update(ctx, bits, 8);encode(digest, ctx.state, 16);}static void transform(uint32 state[4], const unsigned char block[64]){uint32 a = state[0], b = state[1], c = state[2], d = state[3], x[16];decode(x, block, 64);FF(a, b, c, d, x[0], 7, 0xd76aa478);FF(d, a, b, c, x[1], 12, 0xe8c7b756);FF(c, d, a, b, x[2], 17, 0x242070db);FF(b, c, d, a, x[3], 22, 0xc1bdceee);8 行未改动FF(a, b, c, d, x[12], 7, 0x6b901122);FF(d, a, b, c, x[13], 12, 0xfd987193);FF(c, d, a, b, x[14], 17, 0xa679438e);FF(b, c, d, a, x[15], 22, 0x49b40821);GG(a, b, c, d, x[1], 5, 0xf61e2562);GG(d, a, b, c, x[6], 9, 0xc040b340);GG(c, d, a, b, x[11], 14, 0x265e5a51);GG(b, c, d, a, x[0], 20, 0xe9b6c7aa);8 行未改动GG(a, b, c, d, x[13], 5, 0xa9e3e905);GG(d, a, b, c, x[2], 9, 0xfcefa3f8);GG(c, d, a, b, x[7], 14, 0x676f02d9);GG(b, c, d, a, x[12], 20, 0x8d2a4c8a);HH(a, b, c, d, x[5], 4, 0xfffa3942);HH(d, a, b, c, x[8], 11, 0x8771f681);HH(c, d, a, b, x[11], 16, 0x6d9d6122);HH(b, c, d, a, x[14], 23, 0xfde5380c);8 行未改动HH(a, b, c, d, x[9], 4, 0xd9d4d039);HH(d, a, b, c, x[12], 11, 0xe6db99e5);HH(c, d, a, b, x[15], 16, 0x1fa27cf8);HH(b, c, d, a, x[2], 23, 0xc4ac5665);II(a, b, c, d, x[0], 6, 0xf4292244);II(d, a, b, c, x[7], 10, 0x432aff97);II(c, d, a, b, x[14], 15, 0xab9423a7);II(b, c, d, a, x[5], 21, 0xfc93a039);8 行未改动II(a, b, c, d, x[4], 6, 0xf7537e82);II(d, a, b, c, x[11], 10, 0xbd3af235);II(c, d, a, b, x[2], 15, 0x2ad7d2bb);II(b, c, d, a, x[9], 21, 0xeb86d391);state[0] += a;state[1] += b;state[2] += c;state[3] += d;}static inline uint32 F(uint32 x, uint32 y, uint32 z) { return (x & y) | (~x & z); }static inline uint32 G(uint32 x, uint32 y, uint32 z) { return (x & z) | (y & ~z); }static inline uint32 H(uint32 x, uint32 y, uint32 z) { return x ^ y ^ z; }static inline uint32 I(uint32 x, uint32 y, uint32 z) { return y ^ (x | ~z); }static inline void FF(uint32 &a, uint32 b, uint32 c, uint32 d, uint32 x, uint32 s, uint32 t){a += F(b, c, d) + x + t;a = (a << s) | (a >> (32 - s));a += b;}static inline void GG(uint32 &a, uint32 b, uint32 c, uint32 d, uint32 x, uint32 s, uint32 t){a += G(b, c, d) + x + t;a = (a << s) | (a >> (32 - s));a += b;}static inline void HH(uint32 &a, uint32 b, uint32 c, uint32 d, uint32 x, uint32 s, uint32 t){a += H(b, c, d) + x + t;a = (a << s) | (a >> (32 - s));a += b;}static inline void II(uint32 &a, uint32 b, uint32 c, uint32 d, uint32 x, uint32 s, uint32 t){a += I(b, c, d) + x + t;a = (a << s) | (a >> (32 - s));a += b;}static void encode(unsigned char *output, const uint32 *input, size_t length){for (size_t i = 0, j = 0; j < length; i++, j += 4){output[j] = (unsigned char)(input[i] & 0xFF);output[j + 1] = (unsigned char)((input[i] >> 8) & 0xFF);output[j + 2] = (unsigned char)((input[i] >> 16) & 0xFF);output[j + 3] = (unsigned char)((input[i] >> 24) & 0xFF);}}static void decode(uint32 *output, const unsigned char *input, size_t length){for (size_t i = 0, j = 0; j < length; i++, j += 4)output[i] = ((uint32)input[j]) | (((uint32)input[j + 1]) << 8) |(((uint32)input[j + 2]) << 16) | (((uint32)input[j + 3]) << 24);}public:static string hash(const string &input){Context ctx;init(ctx);update(ctx, (const unsigned char*)input.c_str(), input.length());7 行未改动}};//MD5::hash(str)unsigned long long pHash(const string& s){const unsigned long long base = 911382629ULL;const unsigned long long mod = 1000000000000000003ULL;unsigned long long hashValue = 0;// 使用传统for循环兼容C++98for (size_t i = 0; i < s.size(); ++i){char c = s[i];hashValue = (hashValue * base + static_cast<unsigned long long>(c)) % mod;}return hashValue;}struct StringHash{static const unsigned long long base = 911382629ULL;static const unsigned long long mod = 1000000000000000003ULL;vector<unsigned long long> hash;vector<unsigned long long> power;StringHash(const string& s){int n = s.size();hash.resize(n + 1);power.resize(n + 1);power[0] = 1;for (int i = 0; i < n; ++i) {hash[i+1] = (hash[i] * base + static_cast<unsigned long long>(s[i])) % mod;power[i+1] = (power[i] * base) % mod;}}// 获取子串s[l..r]的哈希值(0-based,包含l和r)unsigned long long getHash(int l, int r){int len = r - l + 1;unsigned long long res = (hash[r+1] - hash[l] * power[len]) % mod;if(false) return res+mod;4 行未改动//StringHash strHash(str);//cout << "前缀哈希完整字符串: " << strHash.getHash(0, str.size()-1) << endl;//cout << "子串哈希(0-4): " << strHash.getHash(0, 4) << " (对应\"Hello\")" << endl;size_t Hash(const string& s){size_t hashVal = 0;for (size_t i = 0; i < s.size(); ++i){// 简单的哈希组合算法hashVal = hashVal * 31 + static_cast<size_t>(s[i]);}return hashVal;}string FileMD5(string path){ifstream file(path,ios::in|ios::binary);if (!file.is_open()){return "";}string fileContent;file.seekg(0,ios::end);size_t fileSize = static_cast<size_t>(file.tellg());file.seekg(0,ios::beg);fileContent.reserve(fileSize);fileContent.assign(istreambuf_iterator<char>(file),istreambuf_iterator<char>());if (!file && !file.eof()){return "";}return MD5::hash(fileContent);}#endif#ifdef JTBG_FILEbool Isfileext(const string& filePath){ifstream file(filePath, ios::in | ios::binary);bool exists = file.good();file.close();58 行未改动inline void read((bool)*f{bool})//检测文件读写是否bool fileok(const string &filename){ifstream file(filename);return file.good();}12 行未改动}return ;}void paused(string s){cout<<s<<endl;system("pause > nul");return ;5 行未改动exit(num);return num;}enum Color{BLACK = 0,BLUE = 1,GREEN = 2,34 行未改动return ;}//控制台光标位置控制void setcursor(int x,int y){COORD coord;coord.X = x;coord.Y = y;SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);}//清除控制台指定区域内容void clearCA(int x, int y, int width, int height){for(int i=0;i<height;i++){setcursor(x, y + i);cout << string(width, ' ');}}//隐藏/显示控制台光标void setCVis(bool visible){CONSOLE_CURSOR_INFO cursorInfo = {1, visible};SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursorInfo);}//获取控制台尺寸void getCSize(int &width,int &height){CONSOLE_SCREEN_BUFFER_INFO csbi;GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);width = csbi.srWindow.Right - csbi.srWindow.Left + 1;height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;}void flushed(){cin.ignore(numeric_limits<streamsize>::max(), '\n');cin.clear();return ;7 行未改动return a+rand()%(b+1);}//生成指定长度的随机字符串string randS(int length){const string chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";string result;for (int i = 0; i < length; ++i) {result += chars[rand() % chars.size()];}return result;}double random(double min, double max){return min + (max - min) * (rand() / (double)RAND_MAX);}#endif#ifdef JTBG_STRING/** @brief 在字符串中查找匹配指定模式的位置** @param s 要搜索的目标字符串* @param pattern 匹配模式,支持通配符:* %d - 匹配整数* %Nd - 匹配宽度为N的整数(必须正好N位数字)4 行未改动* %c - 匹配单个字符* %Nc - 匹配N个字符* %% - 匹配百分号字符* 普通字符 - 直接匹配对应字符** @return int 返回匹配开始的索引位置,如果未找到匹配则返回-1** @example* find_in_string("123abc", "%d%s") // 返回0,匹配"123abc"* find_in_string("hello 123", "%s %d") // 返回0,匹配"hello 123"* find_in_string("abc123", "%3s%d") // 返回0,匹配"abc123"* find_in_string("hello world", "%k") // 返回0,匹配整个字符串* find_in_string("5[hi]", "%d[%2s]") // 返回0,匹配"5[hi]"** @note 模式匹配是贪婪的,会尝试从每个位置开始匹配*/int find_in_string(const string& s, const string& pattern){int s_len = s.length();int p_len = pattern.length();// 尝试从每个位置开始匹配for (int start = 0; start <= s_len; ++start){int i = start; // 目标字符串的当前位置int j = 0; // 模式的当前位置bool matched = true;// 遍历模式字符串while (j < p_len && i <= s_len){// 检查是否是通配符4 行未改动{matched = false;break;}j++; // 跳过%// 解析宽度限定符(如果有)int width = 0;bool has_width = false;while (j < p_len && isdigit(pattern[j])){width = width * 10 + (pattern[j] - '0');j++;has_width = true;}// 确保有说明符if (j >= p_len){matched = false;break;}char specifier = pattern[j];j++; // 跳过说明符// 根据说明符处理不同类型的匹配switch (specifier){case 'd': // 匹配整数if (i >= s_len){matched = false;break;}if (has_width){// 固定宽度整数:必须正好匹配width位数字for (int k = 0; k < width; k++)13 行未改动{matched = false;break;}// 可选符号if (s[i] == '-' || s[i] == '+'){i++;}// 匹配一个或多个数字if (i >= s_len || !isdigit(s[i])){matched = false;break;}while (i < s_len && isdigit(s[i])){i++;}}break;case 's': // 匹配非空白字符串if (i >= s_len){matched = false;break;}if (has_width){// 固定宽度字符串:匹配width个任意字符(包括空白符)for (int k = 0; k < width; k++)13 行未改动{matched = false;break;}while (i < s_len && !isspace(s[i])){i++;}}break;case 'k': // 匹配任意字符串(可包含空白符)if (i >= s_len){matched = false;break;}if (has_width){// 固定宽度:匹配width个任意字符for (int k = 0; k < width; k++)11 行未改动// 变长:匹配到字符串结束或遇到模式中的下一个字符// 这里我们采用贪婪匹配,直到字符串结束// 实际的停止条件会在外层循环中处理int next_char = (j < p_len) ? pattern[j] : -1;// 如果没有下一个字符,匹配到字符串结束if (next_char == -1){i = s_len;7 行未改动}}}break;case 'c': // 匹配字符if (i >= s_len){matched = false;break;}if (has_width){// 固定宽度:匹配width个字符for (int k = 0; k < width; k++)11 行未改动// 单个字符i++;}break;case '%': // 匹配百分号if (i >= s_len || s[i] != '%'){matched = false;2 行未改动{i++;}break;default:matched = false;}}7 行未改动}i++;j++;}if (!matched){break;}}// 如果模式完全匹配且目标字符串也匹配完毕if (matched && j == p_len){return start;}}return -1; // 未找到匹配}template<typename T>22 行未改动{int m = s1.length();int n = s2.length();vector<vector<int>> dp(m + 1, vector<int>(n + 1));for (int i = 0; i <= m; i++){dp[i][0] = i;}for (int j = 0; j <= n; j++){dp[0][j] = j;}for (int i = 1; i <= m; i++){for (int j = 1; j <= n; j++){8 行未改动dp[i - 1][j - 1] + 1});}}}return dp[m][n];}template<typename T>10 行未改动if (s1.empty() && s2.empty()){return 100;}int maxLen = max(s1.length(), s2.length());if (maxLen == 0){return 0;}int distance = editDistance(s1, s2);return (int)((1.0 - (double)distance / maxLen) * 100.0);}//检查字符串是否为数字(整数或小数)bool isNumber(const string& str){if (str.empty()) return false;size_t start = 0;if (str[0] == '+' || str[0] == '-') start = 1;bool hasDot = false;for (size_t i = start; i < str.size(); ++i){if (str[i] == '.'){if (hasDot) return false;hasDot = true;}else if (!isdigit(str[i])){return false;}}23 行未改动}return ;}void Testsuper(string &s){if (s.empty()) return;s[0] = toupper(s[0]);for (size_t i = 1; i < s.size();i++){s[i]=tolower(s[i]);}}7 行未改动{if(t!=-1){t*=100;while(t--){if (_kbhit()){int key = _getch();return key;}}return -1;}else{while(1){if (_kbhit()){int key = _getch();return key;}45 行未改动{private:using Clock = chrono::high_resolution_clock;using TimePoint = chrono::time_point<Clock>;TimePoint start_;TimePoint pause_;bool isRunning_;chrono::duration<double> elapsed_;public:Timer() : isRunning_(false), elapsed_(0) {}void starttick(){if (!isRunning_){start_ = Clock::now();isRunning_ = true;}}void pausetick(){if (isRunning_){pause_ = Clock::now();elapsed_ += pause_ - start_;isRunning_ = false;}}void resettick(){isRunning_ = false;elapsed_ = chrono::duration<double>(0);}2 行未改动isRunning_ = false;elapsed_ = chrono::duration<double>(t);return ;}double timesec()const{if (isRunning_){auto now = Clock::now();return (elapsed_ + (now - start_)).count();}return elapsed_.count();}double timemst()const{return timesec() * 1000.0;}};46 行未改动}}string getArchName(int archCode){switch (archCode){case SX64: return "x64 (AMD64)";case SX86: return "x86 (Intel)";case SARM32: return "ARM (32-bit)";29 行未改动{char szPath[MAX_PATH];GetModuleFileName(NULL, szPath, MAX_PATH);SHELLEXECUTEINFO sei;ZeroMemory(&sei,sizeof(sei));sei.cbSize = sizeof(sei);sei.lpVerb = "runas";sei.lpFile = szPath;sei.hwnd = NULL;4 行未改动bool AddToCurrentUserStartup(const string& appName, const string& appPath){HKEY hKey;LONG result;// 使用 RegOpenKeyExA 和 RegSetValueExA (ANSI 版本)result = RegOpenKeyExA(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",0,KEY_WRITE,&hKey);if (result != ERROR_SUCCESS){return false;}// 如果路径包含空格,用引号包围string finalPath = appPath;if (appPath.find(' ') != string::npos && appPath[0] != '\"'){finalPath = "\"" + appPath + "\"";}result = RegSetValueExA(hKey,appName.c_str(),0,REG_SZ,(const BYTE*)finalPath.c_str(),finalPath.size() + 1);RegCloseKey(hKey);return (result == ERROR_SUCCESS);}bool isRun(const char* processName){HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);if (hSnapshot == INVALID_HANDLE_VALUE) return true;PROCESSENTRY32 pe32;pe32.dwSize = sizeof(PROCESSENTRY32);if (Process32First(hSnapshot, &pe32)){do{if (strcmp(pe32.szExeFile, processName) == 0){CloseHandle(hSnapshot);return true;}}while (Process32Next(hSnapshot, &pe32));}CloseHandle(hSnapshot);return false;}void Hide(){HWND hwnd = GetForegroundWindow(); // 获取当前窗口句柄if (hwnd) ShowWindow(hwnd, SW_HIDE); // 隐藏窗口}void Show(){HWND hwnd = GetForegroundWindow(); // 获取当前窗口句柄if (hwnd) ShowWindow(hwnd, SW_SHOW); // 隐藏窗口}12 行未改动return static_cast<long long>(file.tellg());}//延迟函数(高精度ms)void msSleep(int milliseconds){auto start = chrono::high_resolution_clock::now();while (chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() < milliseconds);}//计算文件夹内文件数量(仅统计一级目录)int getFileCountInDir(const string& dirPath){int count = 0;WIN32_FIND_DATA findData;HANDLE hFind = FindFirstFile((dirPath + "\\*").c_str(), &findData);if (hFind == INVALID_HANDLE_VALUE) return -1;do{if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)){count++; // 只统计文件,不统计文件夹}} while (FindNextFile(hFind, &findData) != 0);73 行未改动}#endif#ifdef JTBG_DECANDENCstring xorFile(const string& filePath,const string& key){if (key.empty()){return "";}ifstream file(filePath.c_str(), ios::in | ios::binary);if (!file.is_open()){return "";}string fileContent;char buffer[4096];while (file.read(buffer, sizeof(buffer))){fileContent.append(buffer, sizeof(buffer));}fileContent.append(buffer, file.gcount());const size_t keyLen = key.size();size_t keyIndex = 0;for (string::iterator it = fileContent.begin(); it != fileContent.end(); ++it){*it = static_cast<char>(static_cast<uint8_t>(*it) ^ static_cast<uint8_t>(key[keyIndex]));keyIndex = (keyIndex + 1) % keyLen;}return fileContent;}void xortoFile(const string& filePath,const string& key){if (key.empty()){return ;}ifstream file(filePath.c_str(),ios::in | ios::binary);if (!file.is_open()){return ;}string fileContent;char buffer[4096];while (file.read(buffer, sizeof(buffer))){fileContent.append(buffer, sizeof(buffer));}fileContent.append(buffer, file.gcount());file.close();const size_t keyLen = key.size();size_t keyIndex = 0;for (string::iterator it = fileContent.begin(); it != fileContent.end(); ++it){*it = static_cast<char>(static_cast<uint8_t>(*it) ^ static_cast<uint8_t>(key[keyIndex]));keyIndex = (keyIndex + 1) % keyLen;}ofstream outFile(filePath.c_str(), ios::out | ios::binary | ios::trunc);if (outFile.is_open()){outFile.write(fileContent.data(), fileContent.size());outFile.close();}}void caesarFile(const string& filePath,int shift){shift %= 256;if (shift < 0){shift += 256;}ifstream file(filePath.c_str(), ios::in | ios::binary);if (!file.is_open()){return ;}string fileContent;char buffer[4096];while (file.read(buffer, sizeof(buffer))){fileContent.append(buffer, sizeof(buffer));}fileContent.append(buffer, file.gcount());file.close();for(string::iterator it = fileContent.begin(); it != fileContent.end();it++){*it = static_cast<char>((static_cast<uint8_t>(*it) + shift) % 256);}ofstream outFile(filePath.c_str(), ios::out | ios::binary | ios::trunc);if (outFile.is_open()){outFile.write(fileContent.data(), fileContent.size());outFile.close();}}//加void FileCEnc(const string& filePath, int shift){caesarFile(filePath, shift);}//解void FileCDec(const string& filePath, int shift){caesarFile(filePath, 256 - (shift % 256));}//加密string CEnc(const string& input, int shift){shift %= 256;if (shift < 0){shift += 256;}string result = input;const size_t len = result.size();for (size_t i = 0; i < len; ++i){result[i] = static_cast<char>((static_cast<uint8_t>(result[i]) + shift) % 256);}return result;}//解密string CDec(const string& input, int shift){shift %= 256;if (shift < 0){shift += 256;}return CEnc(input, 256 - shift);}//xor加/解密string xorpass(const string &str, const string &key){string result = str;size_t keyLen = key.size();if (keyLen == 0) return result;3 行未改动}return result;}string base64up(const string &str,const string &base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"){string result;int val = 0, valBits = 0;for (unsigned char c : str){val = (val << 8) + c;valBits += 8;while (valBits >= 6){result += base64Chars[(val >> (valBits - 6)) & 0x3F];valBits -= 6;}}if (valBits > 0){val <<= (6 - valBits);result += base64Chars[val & 0x3F];}while (result.size() % 4 != 0){result += '=';}return result;}string base64dec(const string &str,const string base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"){string result;vector<int> val(4, -1);for (size_t i = 0; i < str.size(); ++i){char c = str[i];if (c == '=') break;size_t pos = base64Chars.find(c);if (pos == string::npos) continue;val[i % 4] = pos;if (i % 4 == 3){result += (val[0] << 2) + ((val[1] >> 4) & 0x3);if (val[2] != -1){result += ((val[1] << 4) & 0xF0) + ((val[2] >> 2) & 0xF);}if (val[3] != -1){result += ((val[2] << 6) & 0xC0) + val[3];}val.assign(4, -1);47 行未改动#define ftop(a,b) NumbertoPercent((a),(b))inline double getSqrtNt(double n,double t){if (n < 0){return NAN;}if (t <= 0){return NAN;}if (n == 0) return 0;double xn = n / 2.0;double xn1 = 0.0;const int MAX_ITER = 1000;int iterCount = 0;do{xn1 = xn - (xn * xn - n) / (2 * xn);if (fabs(xn1 - xn) < t){break;}xn = xn1;iterCount++;} while (iterCount < MAX_ITER);if (iterCount >= MAX_ITER){return NAN;}return xn1;}//角度转弧度inline double toRadians(double degrees){return degrees * DEG_TO_RAD;}// 弧度转角度inline double toDegrees(double radians){return radians * RAD_TO_DEG;}// 计算阶乘inline long long fac(int n){if(n<0) return -1;long long result = 1;for (int i = 2; i <= n; ++i){result *= i;}return result;}inline double qpow(double base, int exponent){if (exponent==0) return 1.0;if (base==0) return 0.0;bool isNegative = exponent < 0;unsigned int absExponent = static_cast<unsigned int>(isNegative ? -exponent : exponent);double result = 1.0;double current = base;while (absExponent > 0){if (absExponent % 2 == 1){result *= current;}current *= current;absExponent /= 2;}return isNegative ? 1.0 / result : result;}inline long long ipow(long long base, int exponent){if (exponent == 0) return 1;if (base == 0) return 0;bool isNegative = false;unsigned int absExp;if (exponent < 0){isNegative = true;absExp = static_cast<unsigned int>(-exponent);}else{absExp = static_cast<unsigned int>(exponent);}long long result = 1;long long current = base;while (absExp > 0){if (absExp & 1){result *= current;}current *= current;absExp >>= 1;}return isNegative ? (result == 0 ? 0 : 1) : result;}inline long long GetA(int a, int b){if(a < 0 || b < 0 || a < b){return -1;}if (b == 0){return 1;}long long result = 1;for (int i = 0; i < b; ++i){result *= (a - i);if (result < 0){return -1;}}return result;}inline long long GetC(int a, int b){if (a < 0 || b < 0 || a < b){return -1;}if (b == 0 || a == b){return 1;}b = min(b, a - b);long long result = 1;for (int i = 1; i <= b; ++i){result = result * (a - b + i) / i;if (result < 0){return -1;}}34 行未改动int sqrt_to = static_cast<int>(sqrt(to));for (int i = 2; i <= sqrt_to; ++i){if (is_prime[i]){for (int j = i * i; j <= to; j += i){is_prime[j] = false;}}}for (int num = from; num <= to; ++num){if (is_prime[num]){primes.push_back(num);}}2 行未改动inline vector<int> MakePrimelist_OLaShai(int from, int to){vector<int> primes;if (from > to || to < 2){return primes;}from=max(from, 2);vector<bool> is_prime(to + 1, true);is_prime[0] = is_prime[1] = false;vector<int> all_primes;for(int i = 2; i <= to; ++i){if (is_prime[i]){all_primes.push_back(i);4 行未改动{break;}is_prime[i * p] = false;if (i % p == 0){break;}}}for(int j=0;j<int(all_primes.size());++j){int p = all_primes[j];if (p >= from && p <= to){primes.push_back(p);}}23 行未改动}}vector<int> primes;from = max(from, 2);for (int p : cache_all_primes){if (p >= from && p <= to) primes.push_back(p);}return primes;17 行未改动shift++;}while ((a & 1) == 0)a >>= 1;do{while ((b & 1) == 0)b >>= 1;if (a < b)21 行未改动shift++;}while ((a & 1) == 0)a >>= 1;do{while ((b & 1) == 0)b >>= 1;if (a < b)6 行未改动inline long long jtbg_lcm(long long a, long long b, bool usesystem = 0){if (a == 0 || b == 0) return 0;long long gcd_val = jtbg_gcd(a, b, usesystem);if (gcd_val == 0) return 0;// lcm(a, b) = |a * b| / gcd(a, b)return llabs(a / gcd_val * b);}inline int jtbg_lcm(int a, int b, bool usesystem = 0){if (a == 0 || b == 0) return 0;int gcd_val = jtbg_gcd(a, b, usesystem);if (gcd_val == 0) return 0;// lcm(a, b) = |a * b| / gcd(a, b)return abs(a / gcd_val * b);}inline long long jtbg_lcm_multi(const vector<long long>& numbers, bool usesystem = 0){if (numbers.empty()) return 0;long long result = numbers[0];for (size_t i = 1; i < numbers.size(); ++i) {result = jtbg_lcm(result, numbers[i], usesystem);if (result == 0) break;103 行未改动全部展开{if (n < 0) return -1;if (n == 0) return 0;if (n == 1) return 1;long long a = 0, b = 1;for (int i = 2; i <= n; ++i){long long temp = a + b;a = b;b = temp;4 行未改动// 判断是否为斐波那契数inline bool jtbg_isFibonacci(int n){if (n < 0) return false;// 一个数是斐波那契数当且仅当 5*n^2+4 或 5*n^2-4 是完全平方数int check1 = 5 * n * n + 4;int check2 = 5 * n * n - 4;return jtbg_isPerfectSquare(check1) || jtbg_isPerfectSquare(check2);}// 计算数字的位数inline int jtbg_countDigits(long long n){if (n == 0) return 1;int count = 0;n = llabs(n);while (n > 0){n /= 10;count++;}4 行未改动inline int jtbg_digitSum(long long n){int sum = 0;n = llabs(n);while (n > 0){sum += n % 10;n /= 10;}5 行未改动{long long reversed = 0;bool negative = n < 0;n = llabs(n);while (n > 0){reversed = reversed * 10 + n % 10;n /= 10;}return negative ? -reversed : reversed;}// 判断回文数266 行未改动全部展开};long long gcd_val = gcd(a, b);a /= gcd_val;b /= gcd_val;while (b % 2 == 0){b /= 2;}while (b % 5 == 0){b /= 5;}if (b == 1){return 0;}long long phi_b = euler_phi(b);vector<long long> divisors = get_divisors(phi_b);for (long long k : divisors){if (quick_pow(10, k, b) == 1){return k;}}return -1;}inline long long int_to_long_long(int i)31 行未改动inline int jtbg_divcnt(int n){if (n <= 0) return 0;if (n == 1) return 1;int cnt = 1;int tmp = n;for (int i = 2; i * i <= tmp; i++){13 行未改动inline int jtbg_divsum(int n){if (n <= 0) return 0;if (n == 1) return 1;int sum = 1;int tmp = n;for (int i = 2; i * i <= tmp; i++){18 行未改动inline long long jtbg_crt(vector<long long> rem, vector<long long> mod){if (rem.size() != mod.size()) return -1;int k = rem.size();long long x = 0;long long M = 1;for (int i = 0; i < k; i++) M *= mod[i];for (int i = 0; i < k; i++){long long Mi = M / mod[i];long long inv = jtbg_modinv(Mi, mod[i]);9 行未改动inline long long jtbg_perm(long long n, long long k){if (n < 0 || k < 0 || k > n) return 0;if (k == 0) return 1;long long res = 1;for (long long i = 0; i < k; i++){if (res > LLONG_MAX / (n - i)) return -1;6 行未改动inline long long jtbg_comb(long long n, long long k){if (n < 0 || k < 0 || k > n) return 0;if (k == 0 || k == n) return 1;if (k > n - k) k = n - k;long long res = 1;for (long long i = 1; i <= k; i++){7 行未改动inline long long jtbg_catalan(int n){if (n < 0) return 0;if (n == 0) return 1;long long res = 1;for (int i = 1; i <= n; i++){res = res * (4 * i - 2) / (i + 1);155 行未改动全部展开inline double jtbg_root_bisect(double (*f)(double), double a, double b, double eps = 1e-10, int maxit = 1000){double fa = f(a);double fb = f(b);if (fa * fb > 0) return NAN; // 同号,区间内可能无根// 确保 fa < 0 < fbif (fa > 0){swap(a, b);swap(fa, fb);}for (int i = 0; i < maxit; i++){double mid = (a + b) / 2;double fm = f(mid);if (fabs(fm) < eps || (b - a) < eps) return mid;if (fm < 0){a = mid;fa = fm;25 行未改动double a3 = 1.421413741;double a4 = -1.453152027;double a5 = 1.061405429;double p = 0.3275911;int sign = (x < 0) ? -1 : 1;x = fabs(x);double t = 1.0 / (1.0 + p * x);double y = 1.0 - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * exp(-x * x);28 行未改动inline bool jtbg_mat2_inv(double m[2][2], double inv[2][2]){double det = jtbg_mat2_det(m);if (fabs(det) < 1e-10) return false;double inv_det = 1.0 / det;inv[0][0] = m[1][1] * inv_det;inv[0][1] = -m[0][1] * inv_det;inv[1][0] = -m[1][0] * inv_det;38 行未改动inline bool jtbg_vec_norm(double v[], int n){double len = jtbg_vec_len(v, n);if (len < 1e-10) return false;for (int i = 0; i < n; i++){v[i] /= len;}30 行未改动inline Complex jtbg_cdiv(Complex a, Complex b){double denom = b.re*b.re + b.im*b.im;if (fabs(denom) < 1e-10) return Complex(NAN, NAN);return Complex((a.re*b.re + a.im*b.im)/denom,(a.im*b.re - a.re*b.im)/denom);}// 复数模长26 行未改动// 复数幂 (a+bi)^ninline Complex jtbg_cpow(Complex c, int n){if (n == 0) return Complex(1, 0);Complex result(1, 0);Complex base = c;bool neg = false;if (n < 0){n = -n;neg = true;}while (n > 0){if (n & 1) result = jtbg_cmul(result, base);base = jtbg_cmul(base, base);n >>= 1;}if (neg){double denom = result.re*result.re + result.im*result.im;if (fabs(denom) < 1e-10) return Complex(NAN, NAN);58 行未改动inline double jtbg_rand_norm(double mu, double sigma){static bool hasSpare = false;static double spare;if (hasSpare){hasSpare = false;return mu + sigma * spare;}double u, v, s;do{u = (rand() / (RAND_MAX + 1.0)) * 2.0 - 1.0;v = (rand() / (RAND_MAX + 1.0)) * 2.0 - 1.0;s = u*u + v*v;} while (s >= 1.0 || s == 0.0);s = sqrt(-2.0 * log(s) / s);spare = v * s;hasSpare = true;return mu + sigma * u * s;7 行未改动return a + (b - a) * t;}// 双线性插值inline double jtbg_bilerp(double q11, double q12, double q21, double q22,double x, double y){double r1 = jtbg_lerp(q11, q21, x);double r2 = jtbg_lerp(q12, q22, x);37 行未改动{out[0] = in[0];return;}Complex* even = new Complex[n/2];Complex* odd = new Complex[n/2];Complex* even_fft = new Complex[n/2];Complex* odd_fft = new Complex[n/2];for (int i = 0; i < n/2; i++){even[i] = in[2*i];odd[i] = in[2*i + 1];}jtbg_fft(even, even_fft, n/2, inverse);jtbg_fft(odd, odd_fft, n/2, inverse);double angle = (inverse ? 2 : -2) * PI / n;Complex w_n(cos(angle), sin(angle));Complex w(1, 0);for (int k = 0; k < n/2; k++){Complex temp = jtbg_cmul(w, odd_fft[k]);out[k] = jtbg_cadd(even_fft[k], temp);6 行未改动out[k + n/2].im /= 2;}w = jtbg_cmul(w, w_n);}delete[] even;delete[] odd;delete[] even_fft;delete[] odd_fft;15 行未改动//===================================== 优化算法 =====================================// 梯度下降inline double jtbg_grad_desc(double (*f)(double), double x0,double lr = 0.01, int iter = 1000){double x = x0;double h = 1e-5;for (int i = 0; i < iter; i++){double grad = (f(x+h) - f(x-h)) / (2*h);x = x - lr * grad;}return x;}// 黄金分割搜索(求最小值)inline double jtbg_golden_search(double (*f)(double),double a, double b,double tol = 1e-7){const double phi = (sqrt(5) - 1) / 2;double c = b - phi * (b - a);double d = a + phi * (b - a);while (fabs(c - d) > tol){if (f(c) < f(d)){16 行未改动// 十进制转二进制字符串inline string jtbg_dec2bin(long long n){if (n == 0) return "0";string result;bool neg = false;if (n < 0){neg = true;n = -n;}while (n > 0){result = char('0' + (n & 1)) + result;n >>= 1;}if (neg) result = "-" + result;return result;}// 二进制字符串转十进制inline long long jtbg_bin2dec(string s){long long result = 0;bool neg = false;if (s[0] == '-'){neg = true;s = s.substr(1);}for (char c : s){result <<= 1;if (c == '1') result |= 1;else if (c != '0') return 0;}return neg ? -result : result;}// 十进制转十六进制inline string jtbg_dec2hex(long long n){if (n == 0) return "0";string result;bool neg = false;const char hex_chars[] = "0123456789ABCDEF";if (n < 0){neg = true;n = -n;}while (n > 0){result = hex_chars[n & 0xF] + result;n >>= 4;}if (neg) result = "-" + result;return result;}// 十六进制转十进制inline long long jtbg_hex2dec(string s){long long result = 0;bool neg = false;if (s[0] == '-'){neg = true;s = s.substr(1);}for (char c : s){result <<= 4;if (c >= '0' && c <= '9')4 行未改动result |= (c - 'a' + 10);elsereturn 0;}return neg ? -result : result;}//===================================== 位运算扩展 =====================================104 行未改动全部展开#define JTBG_QUIK_ENDL '\n'#define jtdl JTBG_QUIK_ENDL#define syst system("cls")#define sys(x) system(x)#define noy_pause() system("pause > nul")#define pause() system("pause")#define to_int(x) atoi(x.c_str()) // 转换为int类型#define to_long(x) stol(x) // 转换为long类型#define to_double(x) stod(x) // 转换为double类型88 行未改动};#endif#ifdef JTBG_LUHNstring prepluhn(const string& input){string result;for(int i=0;i<int(input.size());i++){char c=input[i];if (isdigit(c)){result+=c;}}return result;}int toluhn(const string& num){string number=prepluhn(num);int sum = 0;bool doubleFlag = false;string reversed = number;reverse(reversed.begin(), reversed.end());for(char c : reversed){if (!isdigit(c)){return -1;}int digit = c - '0';if (doubleFlag){digit *= 2;if (digit > 9){digit -= 9;}}sum += digit;doubleFlag = !doubleFlag;}return (10 - (sum % 10)) % 10;}bool visluhn(const string& fb){string fullNumber=prepluhn(fb);if (fullNumber.empty()) return false;string mainPart = fullNumber.substr(0, fullNumber.size() - 1);5 行未改动}#endif#ifdef JTBG_WEBbool Iswebok(){// INTERNET_CONNECTION_MODEM: 调制解调器// INTERNET_CONNECTION_LAN: 局域网// INTERNET_CONNECTION_WWAN: 移动网络(4G/5G)DWORD flags = 0;bool result = InternetGetConnectedState(&flags, 0);if (result){if (flags & INTERNET_CONNECTION_LAN) return 1;//局域网else if (flags & INTERNET_CONNECTION_MODEM) return 2;//调制解调器else return 3;//其他}else return 0;}#endif293 行未改动全部展开string cc_key_j= stdcc.ini_get_vol("key","cc_code");string end_time_j= stdcc.ini_get_vol("cc","end_time");string end_time_key_j= stdcc.ini_get_vol("key","end_time");string ccluhn_j=stdcc.ini_get_vol("cc","luhn");string key=stdcc.ini_get_vol("password","xor");string per=xorpass(per_j,key);string per_key=xorpass(per_key_j,key);string cc=xorpass(cc_j,key);string cc_key=xorpass(cc_key_j,key);string end_time=xorpass(end_time_j,key);string end_time_key=xorpass(end_time_key_j,key);string ccluhn=xorpass(ccluhn_j,key);if(MD5::hash(per)!=per_key) return CC_CHECK_BAD;else if(MD5::hash(cc)!=cc_key) return CC_CHECK_BAD;else if(MD5::hash(end_time)!=end_time_key) return CC_CHECK_BAD;if(int(end_time.size())==8)83 行未改动//GNUSenum class Gnuver{V2,V3,LGPL_V3,CHINESEGNU};string GetGnulicens(Gnuver version = Gnuver::V3){switch (version){case Gnuver::CHINESEGNU:return R"(GNU通用公共许可协议第二版,1991年6月100 行未改动)";case Gnuver::V2:return R"(GNU GENERAL PUBLIC LICENSEVersion 2, June 1991Copyright (C) 1989, 1991 Free Software Foundation, Inc.59 Temple Place - Suite 330, Boston, MA 02111-1307, USAEveryone is permitted to copy and distribute verbatim copiesof this license document, but changing it is not allowed.PreambleThe licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.The precise terms and conditions for copying, distribution and modification follow.TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.NO WARRANTY11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.END OF TERMS AND CONDITIONSHow to Apply These Terms to Your New ProgramsIf you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.one line to give the program's name and an idea of what it does.Copyright (C) yyyy name of author6 行未改动This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.Also add information on how to contact you by electronic and paper mail.If the program is interactive, make it output a short notice like this when it starts in an interactive mode:Gnomovision version 69, Copyright (C) year name of authorGnomovision comes with ABSOLUTELY NO WARRANTY; for detailstype `show w'. This is free software, and you are welcometo redistribute it under certain conditions; type `show c'for details.The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:Yoyodyne, Inc., hereby disclaims all copyrightinterest in the program `Gnomovision'(which makes passes at compilers) writtenby James Hacker.signature of Ty Coon, 1 April 1989Ty Coon, President of ViceThis General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License.)";case Gnuver::V3:return R"(GNU GENERAL PUBLIC LICENSEVersion 3, 29 June 2007Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>Everyone is permitted to copy and distribute verbatim copiesof this license document, but changing it is not allowed.PreambleThe GNU General Public License is a free, copyleft license forsoftware and other kinds of works.The licenses for most software and other practical works are designedto take away your freedom to share and change the works. By contrast,the GNU General Public License is intended to guarantee your freedom toshare and change all versions of a program--to make sure it remains freesoftware for all its users. We, the Free Software Foundation, use theGNU General Public License for most of our software; it applies also toany other work released this way by its authors. You can apply it toyour programs, too.When we speak of free software, we are referring to freedom, notprice. Our General Public Licenses are designed to make sure that youhave the freedom to distribute copies of free software (and charge forthem if you wish), that you receive source code or can get it if youwant it, that you can change the software or use pieces of it in newfree programs, and that you know you can do these things.To protect your rights, we need to prevent others from denying youthese rights or asking you to surrender the rights. Therefore, you havecertain responsibilities if you distribute copies of the software, or ifyou modify it: responsibilities to respect the freedom of others.For example, if you distribute copies of such a program, whethergratis or for a fee, you must pass on to the recipients the samefreedoms that you received. You must make sure that they, too, receiveor can get the source code. And you must show them these terms so theyknow their rights.Developers that use the GNU GPL protect your rights with two steps:(1) assert copyright on the software, and (2) offer you this Licensegiving you legal permission to copy, distribute and/or modify it.For the developers' and authors' protection, the GPL clearly explainsthat there is no warranty for this free software. For both users' andauthors' sake, the GPL requires that modified versions be marked aschanged, so that their problems will not be attributed erroneously toauthors of previous versions.Some devices are designed to deny users access to install or runmodified versions of the software inside them, although the manufacturercan do so. This is fundamentally incompatible with the aim ofprotecting users' freedom to change the software. The systematic2 行未改动have designed this version of the GPL to prohibit the practice for thoseproducts. If such problems arise substantially in other domains, westand ready to extend this provision to those domains in future versionsof the GPL, as needed to protect the freedom of users.Finally, every program is threatened constantly by software patents.States should not allow patents to restrict development and use ofsoftware on general-purpose computers, but in those that do, we wish toavoid the special danger that patents applied to a free program couldmake it effectively proprietary. To prevent this, the GPL assures thatpatents cannot be used to render the program non-free.The precise terms and conditions for copying, distribution andmodification follow.TERMS AND CONDITIONS0. Definitions."This License" refers to version 3 of the GNU General Public License."Copyright" also means copyright-like laws that apply to other kinds ofworks, such as semiconductor masks."The Program" refers to any copyrightable work licensed under thisLicense. Each licensee is addressed as "you". "Licensees" and"recipients" may be individuals or organizations.To "modify" a work means to copy from or adapt all or part of the workin a fashion requiring copyright permission, other than the making of anexact copy. The resulting work is called a "modified version" of theearlier work or a work "based on" the earlier work.A "covered work" means either the unmodified Program or a work basedon the Program.To "propagate" a work means to do anything with it that, withoutpermission, would make you directly or secondarily liable forinfringement under applicable copyright law, except executing it on acomputer or modifying a private copy. Propagation includes copying,distribution (with or without modification), making available to thepublic, and in some countries other activities as well.To "convey" a work means any kind of propagation that enables otherparties to make or receive copies. Mere interaction with a user througha computer network, with no transfer of a copy, is not conveying.An interactive user interface displays "Appropriate Legal Notices"to the extent that it includes a convenient and prominently visiblefeature that (1) displays an appropriate copyright notice, and (2)tells the user that there is no warranty for the work (except to theextent that warranties are provided), that licensees may convey thework under this License, and how to view a copy of this License. Ifthe interface presents a list of user commands or options, such as amenu, a prominent item in the list meets this criterion.1. Source Code.The "source code" for a work means the preferred form of the workfor making modifications to it. "Object code" means any non-sourceform of a work.A "Standard Interface" means an interface that either is an officialstandard defined by a recognized standards body, or, in the case ofinterfaces specified for a particular programming language, one thatis widely used among developers working in that language.The "System Libraries" of an executable work include anything, otherthan the work as a whole, that (a) is included in the normal form ofpackaging a Major Component, but which is not part of that MajorComponent, and (b) serves only to enable use of the work with that2 行未改动"Major Component", in this context, means a major essential component(kernel, window system, and so on) of the specific operating system(if any) on which the executable work runs, or a compiler used toproduce the work, or an object code interpreter used to run it.The "Corresponding Source" for a work in object code form means allthe source code needed to generate, install, and (for an executablework) run the object code and to modify the work, including scripts tocontrol those activities. However, it does not include the work's4 行未改动the work, and the source code for shared libraries and dynamicallylinked subprograms that the work is specifically designed to require,such as by intimate data communication or control flow between thosesubprograms and other parts of the work.The Corresponding Source need not include anything that userscan regenerate automatically from other parts of the CorrespondingSource.The Corresponding Source for a work in source code form is thatsame work.2. Basic Permissions.All rights granted under this License are granted for the term ofcopyright on the Program, and are irrevocable provided the statedconditions are met. This License explicitly affirms your unlimitedpermission to run the unmodified Program. The output from running acovered work is covered by this License only if the output, given itscontent, constitutes a covered work. This License acknowledges yourrights of fair use or other equivalent, as provided by copyright law.You may make, run and propagate covered works that you do notconvey, without conditions so long as your license otherwise remainsin force. You may convey covered works to others for the sole purposeof having them make modifications exclusively for you, or provide you2 行未改动not control copyright. Those thus making or running the covered worksfor you must do so exclusively on your behalf, under your directionand control, on terms that prohibit them from making any copies ofyour copyrighted material outside their relationship with you.Conveying under any other circumstances is permitted solely underthe conditions stated below. Sublicensing is not allowed; section 10makes it unnecessary.3. Protecting Users' Legal Rights From Anti-Circumvention Law.No covered work shall be deemed part of an effective technologicalmeasure under any applicable law fulfilling obligations under article11 of the WIPO copyright treaty adopted on 20 December 1996, orsimilar laws prohibiting or restricting circumvention of suchmeasures.When you convey a covered work, you waive any legal power to forbidcircumvention of technological measures to the extent such circumventionis effected by exercising rights under this License with respect tothe covered work, and you disclaim any intention to limit operation ormodification of the work as a means of enforcing, against the work'susers, your or third parties' legal rights to forbid circumvention oftechnological measures.4. Conveying Verbatim Copies.You may convey verbatim copies of the Program's source code as youreceive it, in any medium, provided that you conspicuously andappropriately publish on each copy an appropriate copyright notice;keep intact all notices stating that this License and anynon-permissive terms added in accord with section 7 apply to the code;keep intact all notices of the absence of any warranty; and give allrecipients a copy of this License along with the Program.You may charge any price or no price for each copy that you convey,and you may offer support or warranty protection for a fee.5. Conveying Modified Source Versions.You may convey a work based on the Program, or the modifications toproduce it from the Program, in the form of source code under theterms of section 4, provided that you also meet all of these conditions:a) The work must carry prominent notices stating that you modifiedit, and giving a relevant date.b) The work must carry prominent notices stating that it is7 行未改动additional terms, to the whole of the work, and all its parts,regardless of how they are packaged. This License gives nopermission to license the work in any other way, but it does notinvalidate such permission if you have separately received it.d) If the work has interactive user interfaces, each must displayAppropriate Legal Notices; however, if the Program has interactiveinterfaces that do not display Appropriate Legal Notices, yourwork need not make them do so.A compilation of a covered work with other separate and independentworks, which are not by their nature extensions of the covered work,and which are not combined with it such as to form a larger program,in or on a volume of a storage or distribution medium, is called an"aggregate" if the compilation and its resulting copyright are notused to limit the access or legal rights of the compilation's usersbeyond what the individual works permit. Inclusion of a covered workin an aggregate does not cause this License to apply to the otherparts of the aggregate.6. Conveying Non-Source Forms.You may convey a covered work in object code form under the termsof sections 4 and 5, provided that you also convey themachine-readable Corresponding Source under the terms of this License,in one of these ways:a) Convey the object code in, or embodied in, a physical product(including a physical distribution medium), accompanied by theCorresponding Source fixed on a durable physical mediumcustomarily used for software interchange.b) Convey the object code in, or embodied in, a physical product(including a physical distribution medium), accompanied by awritten offer, valid for at least three years and valid for aslong as you offer spare parts or customer support for that product3 行未改动medium customarily used for software interchange, for a price nomore than your reasonable cost of physically performing thisconveying of source, or (2) access to copy theCorresponding Source from a network server at no charge.c) Convey individual copies of the object code with a copy of thewritten offer to provide the Corresponding Source. Thisalternative is allowed only occasionally and noncommercially, andonly if you received the object code with such an offer, in accordwith subsection 6b.d) Convey the object code by offering access from a designatedplace (gratis or for a charge), and offer equivalent access to theCorresponding Source in the same way through the same place at nofurther charge. You need not require recipients to copy the4 行未改动clear directions next to the object code saying where to find theCorresponding Source. Regardless of what server hosts theCorresponding Source, you remain obligated to ensure that it isavailable for as long as needed to satisfy these requirements.e) Convey the object code using peer-to-peer transmission, providedyou inform other peers where the object code and CorrespondingSource of the work are being offered to the general public at nocharge under subsection 6d.13 行未改动actually uses, or expects or is expected to use, the product. A productis a consumer product regardless of whether the product has substantialcommercial, industrial or non-consumer uses, unless such uses representthe only significant mode of use of the product."Installation Information" for a User Product means any methods,procedures, authorization keys, or other information required to installand execute modified versions of a covered work in that User Product froma modified version of its Corresponding Source. The information mustsuffice to ensure that the continued functioning of the modified objectcode is in no case prevented or interfered with solely becausemodification has been made.If you convey an object code work under this section in, or with, orspecifically for use in, a User Product, and the conveying occurs aspart of a transaction in which the right of possession and use of theUser Product is transferred to the recipient in perpetuity or for a2 行未改动by the Installation Information. But this requirement does not applyif neither you nor any third party retains the ability to installmodified object code on the User Product (for example, the work hasbeen installed in ROM).The requirement to provide Installation Information does not include arequirement to continue to provide support service, warranty, or updatesfor a work that has been modified or installed by the recipient, or forthe User Product in which it has been modified or installed. Access to anetwork may be denied when the modification itself materially andadversely affects the operation of the network or violates the rules andprotocols for communication across the network.Corresponding Source conveyed, and Installation Information provided,in accord with this section must be in a format that is publiclydocumented (and with an implementation available to the public insource code form), and must require no special password or key forunpacking, reading or copying.7. Additional Terms."Additional permissions" are terms that supplement the terms of thisLicense by making exceptions from one or more of its conditions.Additional permissions that are applicable to the entire Program shallbe treated as though they were included in this License, to the extentthat they are valid under applicable law. If additional permissionsapply only to part of the Program, that part may be used separatelyunder those permissions, but the entire Program remains governed bythis License without regard to the additional permissions.When you convey a copy of a covered work, you may at your optionremove any additional permissions from that copy, or from any part ofit. (Additional permissions may be written to require their ownremoval in certain cases when you modify the work.) You may placeadditional permissions on material, added by you to a covered work,for which you have or can give appropriate copyright permission.Notwithstanding any other provision of this License, for material youadd to a covered work, you may (if authorized by the copyright holders ofthat material) supplement the terms of this License with terms:a) Disclaiming warranty or limiting liability differently from theterms of sections 15 and 16 of this License; orb) Requiring preservation of specified reasonable legal notices or14 行未改动material by anyone who conveys the material (or modified versions ofit) with contractual assumptions of liability to the recipient, forany liability that these contractual assumptions directly impose onthose licensors and authors.All other non-permissive additional terms are considered "furtherrestrictions" within the meaning of section 10. If the Program as youreceived it, or any part of it, contains a notice stating that it isgoverned by this License along with a term that is a furtherrestriction, you may remove that term. If a license document containsa further restriction but permits relicensing or conveying under thisLicense, you may add to a covered work material governed by the termsof that license document, provided that the further restriction doesnot survive such relicensing or conveying.If you add terms to a covered work in accord with this section, youmust place, in the relevant source files, a statement of theadditional terms that apply to those files, or a notice indicatingwhere to find the applicable terms.Additional terms, permissive or non-permissive, may be stated in theform of a separately written license, or stated as exceptions;the above requirements apply either way.10 行未改动provisionally, unless and until the copyright holder explicitly andfinally terminates your license, and (b) permanently, if the copyrightholder fails to notify you of the violation by some reasonable meansprior to 60 days after the cessation.Moreover, your license from a particular copyright holder isreinstated permanently if the copyright holder notifies you of theviolation by some reasonable means, this is the first time you havereceived notice of violation of this License (for any work) from thatcopyright holder, and you cure the violation prior to 30 days afteryour receipt of the notice.Termination of your rights under this section does not terminate thelicenses of parties who have received copies or rights from you underthis License. If your rights have been terminated and not permanentlyreinstated, you do not qualify to receive new licenses for the samematerial under section 10.9. Acceptance Not Required for Having Copies.You are not required to accept this License in order to receive orrun a copy of the Program. Ancillary propagation of a covered workoccurring solely as a consequence of using peer-to-peer transmissionto receive a copy likewise does not require acceptance. However,nothing other than this License grants you permission to propagate ormodify any covered work. These actions infringe copyright if you donot accept this License. Therefore, by modifying or propagating acovered work, you indicate your acceptance of this License to do so.10. Automatic Licensing of Downstream Recipients.Each time you convey a covered work, the recipient automaticallyreceives a license from the original licensors, to run, modify andpropagate that work, subject to this License. You are not responsiblefor enforcing compliance by third parties with this License.An "entity transaction" is a transaction transferring control of anorganization, or substantially all assets of one, or subdividing anorganization, or merging organizations. If propagation of a coveredwork results from an entity transaction, each party to thattransaction who receives a copy of the work also receives whateverlicenses to the work the party's predecessor in interest had or couldgive under the previous paragraph, plus a right to possession of theCorresponding Source of the work from the predecessor in interest, ifthe predecessor has it or can get it with reasonable efforts.You may not impose any further restrictions on the exercise of therights granted or affirmed under this License. For example, you maynot impose a license fee, royalty, or other charge for exercise ofrights granted under this License, and you may not initiate litigation(including a cross-claim or counterclaim in a lawsuit) alleging thatany patent claim is infringed by making, using, selling, offering forsale, or importing the Program or any portion of it.11. Patents.A "contributor" is a copyright holder who authorizes use under thisLicense of the Program or a work on which the Program is based. Thework thus licensed is called the contributor's "contributor version".A contributor's "essential patent claims" are all patent claimsowned or controlled by the contributor, whether already acquired orhereafter acquired, that would be infringed by some manner, permittedby this License, of making, using, or selling its contributor version,but do not include claims that would be infringed only as aconsequence of further modification of the contributor version. Forpurposes of this definition, "control" includes the right to grantpatent sublicenses in a manner consistent with the requirements ofthis License.Each contributor grants you a non-exclusive, worldwide, royalty-freepatent license under the contributor's essential patent claims, tomake, use, sell, offer for sale, import and otherwise run, modify andpropagate the contents of its contributor version.In the following three paragraphs, a "patent license" is any expressagreement or commitment, however denominated, not to enforce a patent(such as an express permission to practice a patent or covenant not tosue for patent infringement). To "grant" such a patent license to aparty means to make such an agreement or commitment not to enforce apatent against the party.If you convey a covered work, knowingly relying on a patent license,and the Corresponding Source of the work is not available for anyoneto copy, free of charge and under the terms of this License, through apublicly available network server or other readily accessible means,5 行未改动actual knowledge that, but for the patent license, your conveying thecovered work in a country, or your recipient's use of the covered workin a country, would infringe one or more identifiable patents in thatcountry that you have reason to believe are valid.If, pursuant to or in connection with a single transaction orarrangement, you convey, or propagate by procuring conveyance of, acovered work, and grant a patent license to some of the partiesreceiving the covered work authorizing them to use, propagate, modifyor convey a specific copy of the covered work, then the patent licenseyou grant is automatically extended to all recipients of the coveredwork and works based on it.A patent license is "discriminatory" if it does not include withinthe scope of its coverage, prohibits the exercise of, or isconditioned on the non-exercise of one or more of the rights that arespecifically granted under this License. You may not convey a covered6 行未改动conveyed by you (or copies made from those copies), or (b) primarilyfor and in connection with specific products or compilations thatcontain the covered work, unless you entered into that arrangement,or that patent license was granted, prior to 28 March 2007.Nothing in this License shall be construed as excluding or limitingany implied license or other defenses to infringement that mayotherwise be available to you under applicable patent law.12. No Surrender of Others' Freedom.If conditions are imposed on you (whether by court order, agreement orotherwise) that contradict the conditions of this License, they do notexcuse you from the conditions of this License. If you cannot convey acovered work so as to satisfy simultaneously your obligations under thisLicense and any other pertinent obligations, then as a consequence you maynot convey it at all. For example, if you agree to terms that obligate youto collect a royalty for further conveying from those to whom you conveythe Program, the only way you could satisfy both those terms and thisLicense would be to refrain entirely from conveying the Program.13. Use with the GNU Affero General Public License.Notwithstanding any other provision of this License, you havepermission to link or combine any covered work with a work licensedunder version 3 of the GNU Affero General Public License into a singlecombined work, and to convey the resulting work. The terms of thisLicense will continue to apply to the part which is the covered work,but the special requirements of the GNU Affero General Public License,section 13, concerning interaction through a network will apply to thecombination as such.14. Revised Versions of this License.The Free Software Foundation may publish revised and/or new versions ofthe GNU General Public License from time to time. Such new versions willbe similar in spirit to the present version, but may differ in detail toaddress new problems or concerns.Each version is given a distinguishing version number. If theProgram specifies that a certain numbered version of the GNU GeneralPublic License "or any later version" applies to it, you have theoption of following the terms and conditions either of that numberedversion or of any later version published by the Free SoftwareFoundation. If the Program does not specify a version number of theGNU General Public License, you may choose any version ever publishedby the Free Software Foundation.If the Program specifies that a proxy can decide which futureversions of the GNU General Public License can be used, that proxy'spublic statement of acceptance of a version permanently authorizes youto choose that version for the Program.Later license versions may give you additional or differentpermissions. However, no additional obligations are imposed on anyauthor or copyright holder as a result of your choosing to follow alater version.15. Disclaimer of Warranty.THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BYAPPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHTHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTYOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULARPURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAMIS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OFALL NECESSARY SERVICING, REPAIR OR CORRECTION.16. Limitation of Liability.IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITINGWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYSTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANYGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THEUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OFDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRDPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OFSUCH DAMAGES.17. Interpretation of Sections 15 and 16.If the disclaimer of warranty and limitation of liability providedabove cannot be given local legal effect according to their terms,reviewing courts shall apply local law that most closely approximatesan absolute waiver of all civil liability in connection with theProgram, unless a warranty or assumption of liability accompanies acopy of the Program in return for a fee.END OF TERMS AND CONDITIONSHow to Apply These Terms to Your New ProgramsIf you develop a new program, and you want it to be of the greatestpossible use to the public, the best way to achieve this is to make itfree software which everyone can redistribute and change under these terms.To do so, attach the following notices to the program. It is safestto attach them to the start of each source file to most effectivelystate the exclusion of warranty; and each file should have at leastthe "copyright" line and a pointer to where the full notice is found.9 行未改动This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program. If not, see <https://www.gnu.org/licenses/>.Also add information on how to contact you by electronic and paper mail.If the program does terminal interaction, make it output a shortnotice like this when it starts in an interactive mode:<program> Copyright (C) <year> <name of author>This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.This is free software, and you are welcome to redistribute itunder certain conditions; type `show c' for details.The hypothetical commands `show w' and `show c' should show the appropriateparts of the General Public License. Of course, your program's commandsmight be different; for a GUI interface, you would use an "about box".You should also get your employer (if you work as a programmer) or school,if any, to sign a "copyright disclaimer" for the program, if necessary.For more information on this, and how to apply and follow the GNU GPL, see<https://www.gnu.org/licenses/>.The GNU General Public License does not permit incorporating your programinto proprietary programs. If your program is a subroutine library, youmay consider it more useful to permit linking proprietary applications withthe library. If this is what you want to do, use the GNU Lesser General2 行未改动)";case Gnuver::LGPL_V3:return R"(GNU LESSER GENERAL PUBLIC LICENSEVersion 3, 29 June 2007Copyright ? 2007 Free Software Foundation, Inc. <https://fsf.org/>Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.0. Additional Definitions.As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.1. Exception to Section 3 of the GNU GPL.You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.2. Conveying Modified Versions.If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, orb) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.3. Object Code Incorporating Material from Library Header Files.The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.b) Accompany the object code with a copy of the GNU GPL and this license document.4. Combined Works.You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.b) Accompany the Combined Work with a copy of the GNU GPL and this license document.c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.d) Do one of the following:0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)5. Combined Libraries.You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.6. Revised Versions of the GNU Lesser General Public License.The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.29 行未改动if (a == b) return "0";// 如果 a < b,交换并标记负号bool isNegative = false;if (!isGreaterOrEqual(a, b)){swap(a, b);isNegative = true;}string result;int i = a.size() - 1, j = b.size() - 1;int borrow = 0;while (i >= 0){int digitA = (a[i] - '0') - borrow;int digitB = (j >= 0) ? (b[j--] - '0') : 0;if (digitA < digitB){digitA += 10;borrow = 1;}else{borrow = 0;}17 行未改动return a >= b;}// 移除前导零void removeLeadingZeros(){size_t start = num.find_first_not_of('0');if (start == string::npos){num = "0";sign = true; // 0的符号为正}else{num = num.substr(start);}14 行未改动{sum += (a[i] - '0');i--;}if (j >= 0){sum += (b[j] - '0');j--;}80 行未改动Bigint() : num("0"), sign(true) {}Bigint(string s){if (s.empty()){num = "0";sign = true;return;3 行未改动if (s[0] == '-'){sign = false;s = s.substr(1);}else{sign = true;}5 行未改动return;}// 移除前导零size_t start = s.find_first_not_of('0');if (start == string::npos){num = "0";sign = true; // 0总是正数}else{num = s.substr(start);// 如果数字是"0",确保符号为正if (num == "0") sign = true;15 行未改动string a = this->num;string b = other.num;bool aSign = this->sign;bool bSign = other.sign;if (aSign == bSign){string result = add(a, b);return Bigint(aSign ? result : "-" + result);}else{if (aSign) // a正,b负 => a - |b|{string result = subtractNonNegative(a, b);if (result[0] == '-'){return Bigint("-" + result.substr(1));}else{return Bigint(result);}}else // a负,b正 => b - |a|{string result = subtractNonNegative(b, a);if (result[0] == '-'){return Bigint("-" + result.substr(1));}else{return Bigint(result);}}18 行未改动// 除法运算符Bigint operator/(const Bigint& other) const{if (other.num == "0"){throw runtime_error("Division by zero");}7 行未改动// 取模运算符Bigint operator%(const Bigint& other) const{if (other.num == "0"){throw runtime_error("Modulo by zero");}// 计算 a % b = a - (a / b) * bBigint quotient = *this / other;Bigint product = quotient * other;Bigint remainder = *this - product;return remainder;}Bigint& operator+=(const Bigint& other){19 行未改动{*this = *this % other;return *this;}bool operator==(const Bigint& other) const{return (sign == other.sign) && (num == other.num);}bool operator!=(const Bigint& other) const{return !(*this == other);}bool operator<(const Bigint& other) const{if (sign != other.sign){return sign < other.sign; // 负数 < 正数}if (sign) // 都是正数{if (num.length() != other.num.length())return num.length() < other.num.length();return num < other.num;}else // 都是负数{if (num.length() != other.num.length())return num.length() > other.num.length();return num > other.num;}}bool operator>(const Bigint& other) const{return other < *this;}bool operator<=(const Bigint& other) const{return !(*this > other);}bool operator>=(const Bigint& other) const{return !(*this < other);}friend ostream& operator<<(ostream& os, const Bigint& bigint){if (!bigint.sign && bigint.num != "0"){os << '-';22 行未改动};#endif#ifdef JTBG_KMPstruct kmp{private:string pattern;vector<int> next;2 行未改动int m = pattern.length();next.resize(m, 0);next[0] = -1;int i = 0, j = -1;while (i < m - 1){if (j == -1 || pattern[i] == pattern[j]){i++;j++;next[i] = j;}else{j = next[j];}}}public:kmp(const string& pat) : pattern(pat){buildNext();}// 搜索所有匹配位置vector<int> search(const string& text){vector<int> result;int n = text.length();int m = pattern.length();if (m == 0) return result;int i = 0, j = 0;while (i < n) {if (j == -1 || text[i] == pattern[j]){i++;j++;}else{j = next[j];}if (j == m){result.push_back(i - j);j = next[j - 1]; // 继续搜索i--; // 回退一步}}return result;}// 搜索第一个匹配位置,返回-1表示未找到int findFirst(const string& text){int n = text.length();int m = pattern.length();if (m == 0) return 0;int i = 0, j = 0;while (i < n && j < m){if (j == -1 || text[i] == pattern[j]){i++;j++;}else{j = next[j];}}return (j == m) ? (i - j) : -1;}// 判断是否包含模式串bool contains(const string& text){return findFirst(text) != -1;}// 获取next数组(用于调试)vector<int> getNext() const{return next;}// 统计匹配次数int count(const string& text){return search(text).size();}};5 行未改动void pre(int argc,char** argv){cout << "程序名: " << argv[0] << endl;cout << "参数数量: " << argc - 1 << endl;for (int i = 1; i < argc; i++){cout << "参数 " << i << ": " << argv[i] << endl;}}vector<string> ToVector(int argc, char** argv){vector<string> args;for (int i = 1; i < argc; i++){args.push_back(string(argv[i]));}return args;}map<string, string> ToKeyValue(int argc, char** argv){map<string, string> params;for (int i = 1; i < argc; i++){string arg = argv[i];// 检查是否是 --key=value 格式if (arg.substr(0, 2) == "--"){size_t pos = arg.find('=');if (pos != string::npos){string key = arg.substr(2, pos - 2);string value = arg.substr(pos + 1);params[key] = value;}else{// 只有键没有值params[arg.substr(2)] = "true";}}// 检查是否是 -key value 格式else if (arg.substr(0, 1) == "-"){string key = arg.substr(1);if (i + 1 < argc && argv[i + 1][0] != '-'){params[key] = argv[i + 1];i++; // 跳过下一个参数}else{params[key] = "true";}}}return params;}};#endif84 行未改动0,KEY_SET_VALUE,&hKey);if (ret != ERROR_SUCCESS){return false;}// 设置DWORD类型键值ret = RegSetValueExW(hKey,valueName,0,REG_DWORD,(const BYTE*)&value,sizeof(DWORD));if (ret != ERROR_SUCCESS){RegCloseKey(hKey);return false;}RegCloseKey(hKey); // 关闭注册表句柄return true;}bool SetShowFileExtensions(bool showExt=1)8 行未改动0, // 保留参数KEY_SET_VALUE, // 访问权限&hKey // 输出打开的键句柄);if (ret != ERROR_SUCCESS){return false;}// 2. 设置键值:0表示显示,1表示隐藏5 行未改动REG_DWORD, // 数据类型(32位整数)(const BYTE*)&value,// 数据缓冲区sizeof(DWORD) // 数据长度);if (ret != ERROR_SUCCESS){RegCloseKey(hKey); // 关闭注册表句柄return false;}3 行未改动SHCNF_IDLIST, // 数据类型:ID列表(无具体数据时用此)nullptr, // 无具体数据nullptr // 无具体数据);return true;}bool SetShowHiddenFiles(bool show){const wchar_t* regPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced";DWORD value = show ? 1 : 2; // 注意:Hidden键的取值是1=显示,2=隐藏(特殊规则)if (!SetRegistryDwordValue(regPath, L"Hidden", value)){return false;}return true;}bool SetShowSystemFiles(bool show){const wchar_t* regPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced";DWORD value = show ? 1 : 0; // 1=显示系统文件,0=隐藏if (!SetRegistryDwordValue(regPath, L"ShowSuperHidden", value)){return false;}return true;}bool SetHideEmptyDrives(bool hide){const wchar_t* regPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced";DWORD value = hide ? 1 : 0; // 1=隐藏无介质驱动器,0=显示if (!SetRegistryDwordValue(regPath, L"HideDrivesWithNoMedia", value)){return false;}return true;}bool ReadRegistryString(HKEY rootKey, const wchar_t* subKey, const wchar_t* valueName, wstring& outStr){HKEY hKey = nullptr;LONG ret = RegOpenKeyExW(rootKey, subKey, 0, KEY_READ, &hKey);if (ret != ERROR_SUCCESS){return false;}// 第一步:调用RegQueryValueExW获取字符串的长度(dataSize返回所需缓冲区大小)DWORD dataType = 0;DWORD dataSize = 0;ret = RegQueryValueExW(3 行未改动&dataType,nullptr, // 缓冲区为null,仅获取长度&dataSize);if (ret != ERROR_SUCCESS && ret != ERROR_MORE_DATA){RegCloseKey(hKey);return false;}// 第二步:分配缓冲区,读取字符串bool success = false;if (dataType == REG_SZ || dataType == REG_EXPAND_SZ){wchar_t* buffer = new wchar_t[dataSize / sizeof(wchar_t)]; // 按宽字符分配ret = RegQueryValueExW(hKey,2 行未改动&dataType,(LPBYTE)buffer,&dataSize);if (ret == ERROR_SUCCESS){outStr = buffer; // 赋值到wstringsuccess = true;}delete[] buffer; // 释放缓冲区}RegCloseKey(hKey);return success;}bool ReadRegistryDword(HKEY rootKey, const wchar_t* subKey, const wchar_t* valueName, DWORD& outValue){HKEY hKey = nullptr;LONG ret = RegOpenKeyExW(rootKey,subKey,0,KEY_READ,&hKey);if (ret != ERROR_SUCCESS){return false;}// 2. 查询键值:先获取数据长度(此处DWORD固定为4字节,也可动态获取)DWORD dataType = 0;DWORD dataSize = sizeof(DWORD);ret = RegQueryValueExW(3 行未改动&dataType, // 输出实际值类型(LPBYTE)&outValue, // 存储读取的数据&dataSize // 输入缓冲区大小,输出实际数据大小);// 3. 校验结果:类型匹配 + 操作成功bool success = false;if (ret == ERROR_SUCCESS){if (dataType == REG_DWORD){success = true;}}RegCloseKey(hKey);return success;}47 行未改动#define RESUME 0#define SUSPEND 1#ifndef NO_DEBUGPROSDWORD GetProcessIdByName(const char* processName){DWORD processId = 0;HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);if (hSnapshot != INVALID_HANDLE_VALUE){PROCESSENTRY32 processEntry;processEntry.dwSize = sizeof(PROCESSENTRY32);if (Process32First(hSnapshot, &processEntry)){do{if (strcmp(processEntry.szExeFile, processName) == 0){processId = processEntry.th32ProcessID;6 行未改动return processId;}// 使用DebugActiveProcess挂起进程bool SuspendProcessByDebug(DWORD processId){if (DebugActiveProcess(processId)){return true;3 行未改动// 恢复被Debug挂起的进程bool ResumeProcessByDebug(DWORD processId){if (DebugActiveProcessStop(processId)){return true;}return false;10 行未改动#ifndef NO_NTPPORStypedef LONG (NTAPI *NtSuspendProcess)(IN HANDLE ProcessHandle);typedef LONG (NTAPI *NtResumeProcess)(IN HANDLE ProcessHandle);// 使用NtSuspendProcess挂起进程bool SuspendProcessByNt(DWORD processId){HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);if (hProcess == NULL){return false;}// 获取NtSuspendProcess函数HMODULE hNtDll = GetModuleHandle("ntdll.dll");if (hNtDll == NULL){CloseHandle(hProcess);return false;}NtSuspendProcess pNtSuspendProcess =(NtSuspendProcess)GetProcAddress(hNtDll, "NtSuspendProcess");if (pNtSuspendProcess != NULL){LONG status = pNtSuspendProcess(hProcess);CloseHandle(hProcess);if (status == 0){ // STATUS_SUCCESScout << "进程 " << processId << " 已被挂起 (Nt方法)" << endl;return true;}}CloseHandle(hProcess);return false;}// 恢复进程bool ResumeProcessByNt(DWORD processId){HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);if (hProcess == NULL){return false;}HMODULE hNtDll = GetModuleHandle("ntdll.dll");if (hNtDll == NULL){CloseHandle(hProcess);return false;}NtResumeProcess pNtResumeProcess =(NtResumeProcess)GetProcAddress(hNtDll, "NtResumeProcess");if (pNtResumeProcess != NULL){LONG status = pNtResumeProcess(hProcess);CloseHandle(hProcess);if (status == 0){cout << "进程 " << processId << " 已恢复 (Nt方法)" << endl;return true;}}CloseHandle(hProcess);return false;}8 行未改动#ifndef NO_TerminateProcessbool KillProcByTer(DWORD processId, UINT exitCode = 0){HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, processId);if (hProcess == NULL){return false;}if (TerminateProcess(hProcess, exitCode)){CloseHandle(hProcess);return true;}else{CloseHandle(hProcess);return false;}}#endif#ifndef NO_NTTERMINATEtypedef LONG (NTAPI *NtTerminateProcess)(HANDLE ProcessHandle, LONG ExitStatus);bool KillProcByNt(DWORD processId, LONG exitCode = 0){HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, processId);if (hProcess == NULL){return false;}HMODULE hNtDll = GetModuleHandle("ntdll.dll");if (hNtDll == NULL){CloseHandle(hProcess);return false;}NtTerminateProcess pNtTerminateProcess =(NtTerminateProcess)GetProcAddress(hNtDll, "NtTerminateProcess");if (pNtTerminateProcess != NULL){LONG status = pNtTerminateProcess(hProcess, exitCode);CloseHandle(hProcess);if (status == 0){ // STATUS_SUCCESSreturn true;}}CloseHandle(hProcess);return false;}#endifBOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam){DWORD targetProcessId = (DWORD)lParam;DWORD windowProcessId;GetWindowThreadProcessId(hwnd, &windowProcessId);if (windowProcessId == targetProcessId){// 发送关闭消息PostMessage(hwnd, WM_CLOSE, 0, 0);5 行未改动// 向进程的所有窗口发送关闭消息EnumWindows(EnumWindowsProc, (LPARAM)processId);// 等待进程退出HANDLE hProcess = OpenProcess(SYNCHRONIZE, FALSE, processId);if (hProcess == NULL){return KillProcByTer(processId);}DWORD waitResult = WaitForSingleObject(hProcess, waitTimeout);CloseHandle(hProcess);if (waitResult == WAIT_OBJECT_0){return true;}else{return KillProcByTer(processId);}}#endif#ifdef JTBG_UDPclass UDPSocket{public:// 手动实现 inet_pton (字符串转网络地址)static inet_pton(int af, const char* src, void* dst){if (af != AF_INET){return -1; // 只支持 IPv4}uint32_t ip=0;int parts[4];int count = sscanf(src, "%d.%d.%d.%d", &parts[0], &parts[1], &parts[2], &parts[3]);if (count != 4){return 0; // 格式错误}for (int i = 0; i < 4; i++){if (parts[i] < 0 || parts[i] > 255){return 0; // 数值越界}ip = (ip << 8) | (parts[i] & 0xFF);}*((uint32_t*)dst) = htonl(ip);return 1;}// 手动实现 inet_ntop (网络地址转字符串)static const char* inet_ntop(int af, const void* src, char* dst, socklen_t size){if (af != AF_INET || size < INET_ADDRSTRLEN){return nullptr;}uint32_t ip = ntohl(*((const uint32_t*)src));snprintf(dst, size, "%d.%d.%d.%d",(ip >> 24) & 0xFF,(ip >> 16) & 0xFF,(ip >> 8) & 0xFF,ip & 0xFF);return dst;}using ReceiveCallback = function<void(const vector<uint8_t>& data,const sockaddr_in& from,int dataSize)>;using ErrorCallback = function<void(const string& error)>;// 构造函数和析构函数UDPSocket();~UDPSocket();// 禁止拷贝UDPSocket(const UDPSocket&) = delete;UDPSocket& operator=(const UDPSocket&) = delete;// 移动构造和赋值UDPSocket(UDPSocket&& other) noexcept;UDPSocket& operator=(UDPSocket&& other) noexcept;// 基本操作bool create();bool bind(uint16_t port, const string& address = "0.0.0.0");bool close();// 发送数据int sendTo(const vector<uint8_t>& data,const string& ip, uint16_t port);int sendTo(const uint8_t* data, size_t size,const string& ip, uint16_t port);// 接收数据(阻塞模式)int receiveFrom(vector<uint8_t>& buffer,string& fromIP, uint16_t& fromPort,int timeoutMs = -1);// 设置套接字选项bool setBroadcast(bool enable);bool setReuseAddress(bool enable);bool setNonBlocking(bool enable);bool setReceiveBufferSize(int size);bool setSendBufferSize(int size);bool setTTL(int ttl);// 异步操作bool startAsyncReceive(const ReceiveCallback& receiveCallback,const ErrorCallback& errorCallback = nullptr);void stopAsyncReceive();// 属性获取bool isValid() const { return socket_ != INVALID_SOCKET; }uint16_t getLocalPort() const { return localPort_; }string getLocalAddress() const { return localAddress_; }bool isAsyncReceiving() const { return asyncReceiving_; }private:SOCKET socket_;string localAddress_;uint16_t localPort_;// 异步接收相关atomic<bool> asyncReceiving_;thread receiveThread_;ReceiveCallback receiveCallback_;ErrorCallback errorCallback_;// 初始化Winsockstatic bool initializeWinsock();static void cleanupWinsock();static atomic<int> winsockRefCount_;// 线程函数void asyncReceiveThread();// 工具函数static string ipToString(const sockaddr_in& addr);static uint16_t portFromSockaddr(const sockaddr_in& addr);static bool stringToSockaddr(const string& ip, uint16_t port, sockaddr_in& addr);};// 实现部分inline UDPSocket::UDPSocket(): socket_(INVALID_SOCKET), localPort_(0), asyncReceiving_(false){initializeWinsock();}inline UDPSocket::~UDPSocket(){close();stopAsyncReceive();cleanupWinsock();2 行未改动inline UDPSocket::UDPSocket(UDPSocket&& other) noexcept: socket_(other.socket_), localAddress_(move(other.localAddress_)), localPort_(other.localPort_), asyncReceiving_(other.asyncReceiving_.load()){other.socket_ = INVALID_SOCKET;other.asyncReceiving_ = false;}inline UDPSocket& UDPSocket::operator=(UDPSocket&& other) noexcept{if (this != &other){close();stopAsyncReceive();socket_ = other.socket_;localAddress_ = move(other.localAddress_);localPort_ = other.localPort_;asyncReceiving_ = other.asyncReceiving_.load();other.socket_ = INVALID_SOCKET;other.asyncReceiving_ = false;}return *this;}inline bool UDPSocket::initializeWinsock(){if (winsockRefCount_++ == 0){WSADATA wsaData;WORD version = MAKEWORD(2, 2);if (WSAStartup(version, &wsaData) != 0){winsockRefCount_--;return false;}}return true;}inline void UDPSocket::cleanupWinsock(){if (--winsockRefCount_ == 0){WSACleanup();}}inline bool UDPSocket::create(){if (socket_ != INVALID_SOCKET){return true;}socket_ = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);if (socket_ == INVALID_SOCKET){return false;}return true;}inline bool UDPSocket::bind(uint16_t port, const string& address){if (!create()){return false;}sockaddr_in addr;if (!stringToSockaddr(address, port, addr)){return false;}if (::bind(socket_, reinterpret_cast<sockaddr*>(&addr), sizeof(addr)) == SOCKET_ERROR){return false;}// 获取绑定后的地址信息sockaddr_in localAddr;int addrLen = sizeof(localAddr);if (getsockname(socket_, reinterpret_cast<sockaddr*>(&localAddr), &addrLen) == 0){localAddress_ = ipToString(localAddr);localPort_ = portFromSockaddr(localAddr);}return true;}inline bool UDPSocket::close(){if (socket_ != INVALID_SOCKET){::closesocket(socket_);socket_ = INVALID_SOCKET;}return true;}inline int UDPSocket::sendTo(const vector<uint8_t>& data,const string& ip, uint16_t port){return sendTo(data.data(), data.size(), ip, port);}inline int UDPSocket::sendTo(const uint8_t* data, size_t size,const string& ip, uint16_t port){if (socket_ == INVALID_SOCKET || !data || size == 0){return -1;}sockaddr_in addr;if (!stringToSockaddr(ip, port, addr)){return -1;}int sent = ::sendto(socket_,reinterpret_cast<const char*>(data),static_cast<int>(size),0,reinterpret_cast<sockaddr*>(&addr),sizeof(addr));if (sent == SOCKET_ERROR){return -1;}return sent;}inline int UDPSocket::receiveFrom(vector<uint8_t>& buffer,string& fromIP, uint16_t& fromPort,int timeoutMs) {if (socket_ == INVALID_SOCKET){return -1;}// 设置超时if (timeoutMs >= 0){fd_set readSet;FD_ZERO(&readSet);FD_SET(socket_, &readSet);timeval timeout;timeout.tv_sec = timeoutMs / 1000;timeout.tv_usec = (timeoutMs % 1000) * 1000;int result = select(0, &readSet, nullptr, nullptr, &timeout);if (result == 0){return 0; // 超时}else if (result == SOCKET_ERROR){return -1;}}sockaddr_in fromAddr;int fromLen = sizeof(fromAddr);int received = ::recvfrom(socket_,reinterpret_cast<char*>(buffer.data()),static_cast<int>(buffer.size()),0,reinterpret_cast<sockaddr*>(&fromAddr),&fromLen);if (received == SOCKET_ERROR){return -1;}fromIP = ipToString(fromAddr);fromPort = portFromSockaddr(fromAddr);return received;}inline bool UDPSocket::setBroadcast(bool enable){if (socket_ == INVALID_SOCKET) return false;BOOL broadcast = enable ? TRUE : FALSE;return setsockopt(socket_, SOL_SOCKET, SO_BROADCAST,reinterpret_cast<char*>(&broadcast), sizeof(broadcast)) == 0;}inline bool UDPSocket::setReuseAddress(bool enable){if (socket_ == INVALID_SOCKET) return false;BOOL reuse = enable ? TRUE : FALSE;return setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR,reinterpret_cast<char*>(&reuse), sizeof(reuse)) == 0;}inline bool UDPSocket::setNonBlocking(bool enable){if (socket_ == INVALID_SOCKET) return false;u_long mode = enable ? 1 : 0;return ioctlsocket(socket_, FIONBIO, &mode) == 0;}inline bool UDPSocket::setReceiveBufferSize(int size){if (socket_ == INVALID_SOCKET) return false;return setsockopt(socket_, SOL_SOCKET, SO_RCVBUF,reinterpret_cast<char*>(&size), sizeof(size)) == 0;}inline bool UDPSocket::setSendBufferSize(int size){if (socket_ == INVALID_SOCKET) return false;return setsockopt(socket_, SOL_SOCKET, SO_SNDBUF,reinterpret_cast<char*>(&size), sizeof(size)) == 0;}inline bool UDPSocket::setTTL(int ttl){if (socket_ == INVALID_SOCKET) return false;return setsockopt(socket_, IPPROTO_IP, IP_TTL,reinterpret_cast<char*>(&ttl), sizeof(ttl)) == 0;}inline bool UDPSocket::startAsyncReceive(const ReceiveCallback& receiveCallback,const ErrorCallback& errorCallback){if (socket_ == INVALID_SOCKET || asyncReceiving_){return false;}receiveCallback_ = receiveCallback;errorCallback_ = errorCallback;asyncReceiving_ = true;receiveThread_ = thread(&UDPSocket::asyncReceiveThread, this);return true;}inline void UDPSocket::stopAsyncReceive(){if (asyncReceiving_){asyncReceiving_ = false;if (receiveThread_.joinable()){receiveThread_.join();}}}inline void UDPSocket::asyncReceiveThread(){vector<uint8_t> buffer(65507); // UDP最大数据包大小while (asyncReceiving_){string fromIP;uint16_t fromPort;int received = receiveFrom(buffer, fromIP, fromPort, 100); // 100ms超时if (received > 0 && receiveCallback_){sockaddr_in fromAddr;if (stringToSockaddr(fromIP, fromPort, fromAddr)){vector<uint8_t> data(buffer.begin(), buffer.begin() + received);receiveCallback_(data, fromAddr, received);}} else if (received == SOCKET_ERROR && errorCallback_){errorCallback_("接收数据出错");}}19 行未改动{memset(&addr, 0, sizeof(addr));addr.sin_family = AF_INET;addr.sin_port = htons(port);if (ip.empty() || ip == "0.0.0.0"){addr.sin_addr.s_addr = INADDR_ANY;}else if (ip == "255.255.255.255"){addr.sin_addr.s_addr = INADDR_BROADCAST;}else{if (inet_pton(AF_INET, ip.c_str(), &addr.sin_addr) != 1){return false;}}return true;}#endif6 行未改动#define PROGRESS_STYLE_DEFAULT "|"#define PROGRESS_STYLE_BLOCK "="#define PROGRESS_STYLE_DASH "-"class BarDrawer{ // 修正类名与使用处一致private:int total; // 总进度值int current; // 当前进度值int barLength; // 进度条长度string style; // 进度条样式bool showPercent; // 是否显示百分比bool showTime; // 是否显示时间chrono::steady_clock::time_point startTime; // 开始时间public:// 构造函数(修正:使用正确的构造函数语法)BarDrawer(int totalSteps, int length = 50,string barStyle = PROGRESS_STYLE_DEFAULT,bool percent = true, bool time = true): total(totalSteps), current(0), barLength(length),style(barStyle), showPercent(percent), showTime(time){startTime = chrono::steady_clock::now();}// 无参构造函数(解决实例化时的参数匹配问题)BarDrawer(): total(100), current(0), barLength(50),style(PROGRESS_STYLE_DEFAULT), showPercent(true), showTime(true){startTime = chrono::steady_clock::now();}// 更新进度void update(int steps = 1){current = min(current + steps, total);draw();}// 直接设置进度void setProgress(int value){current = max(0, min(value, total));draw();}// 完成进度void finish(){current = total;draw();cout << endl;}// 绘制进度条(修正:添加返回值或改为void)void draw(){double progress = static_cast<double>(current) / total;int filledLength = static_cast<int>(progress * barLength);// 计算已用时间auto now = chrono::steady_clock::now();auto elapsed = chrono::duration_cast<chrono::seconds>(now - startTime).count();// 绘制进度条(结合JTBG_COL模块的颜色功能)scg(LIGHT_GREEN, BLACK); // 设置绿色文本cout << "\r[";for (int i = 0; i < barLength; ++i){if (i < filledLength) cout << style;else cout << " ";}cout << "] ";// 显示百分比if (showPercent){scg(LIGHT_CYAN, BLACK); // 百分比用青色cout << fixed << setprecision(1)<< progress * 100 << "% ";}// 显示进度数值scg(WHITE, BLACK); // 数值用白色cout << current << "/" << total;// 显示时间if(showTime){scg(YELLOW, BLACK);cout << " (" << elapsed << "s)";}scg(WHITE, BLACK); // 恢复默认颜色cout.flush();}};12 行未改动{private:string num;bool negative;// 移除前导零void removeLeadingZeros(){size_t pos = num.find_first_not_of('0');if (pos == string::npos){num = "0";negative = false;}else{num = num.substr(pos);}if (num == "0") negative = false;}// 比较绝对值大小int compareAbsolute(const SimpleBigInt& other) const{if (num.length() != other.num.length()){return num.length() > other.num.length() ? 1 : -1;}return num.compare(other.num);}public:// 构造函数SimpleBigInt() : num("0"), negative(false) {}SimpleBigInt(long long n){if (n < 0){negative = true;n = -n;}else{negative = false;}num = to_string(n);}SimpleBigInt(const string& s){if (s.empty()){num = "0";negative = false;}else{if (s[0] == '-'){negative = true;num = s.substr(1);}else{negative = false;num = s;}}removeLeadingZeros();}// 转换为字符串string toString() const{return (negative ? "-" : "") + num;}// 获取数字字符串(无符号)string getNum() const{return num;}// 获取符号bool isNegative() const{return negative;}// 比较运算符bool operator==(const SimpleBigInt& other) const{return negative == other.negative && num == other.num;}bool operator!=(const SimpleBigInt& other) const{return !(*this == other);}bool operator<(const SimpleBigInt& other) const{if (negative != other.negative){4 行未改动return compareAbsolute(other) > 0;}return compareAbsolute(other) < 0;}bool operator<=(const SimpleBigInt& other) const{return *this < other || *this == other;}bool operator>(const SimpleBigInt& other) const{return !(*this <= other);}bool operator>=(const SimpleBigInt& other) const{return !(*this < other);}// 加法SimpleBigInt operator+(const SimpleBigInt& other) const{if (negative != other.negative){// 符号不同,转换为减法if (negative){SimpleBigInt temp = *this;temp.negative = false;return other - temp;}else{SimpleBigInt temp = other;temp.negative = false;return *this - temp;}}// 符号相同,直接相加string result;int carry = 0;int i = num.length() - 1;int j = other.num.length() - 1;while (i >= 0 || j >= 0 || carry > 0){int digit1 = i >= 0 ? num[i] - '0' : 0;int digit2 = j >= 0 ? other.num[j] - '0' : 0;int sum = digit1 + digit2 + carry;result.push_back((sum % 10) + '0');carry = sum / 10;i--;j--;}reverse(result.begin(), result.end());SimpleBigInt res(result);res.negative = negative;return res;}// 减法SimpleBigInt operator-(const SimpleBigInt& other) const{if (negative != other.negative){// 符号不同,转换为加法SimpleBigInt temp = other;temp.negative = !other.negative;return *this + temp;}// 符号相同,比较大小bool resultNegative = false;string a = num;string b = other.num;if (negative){// 都是负数:(-a) - (-b) = b - aswap(a, b);resultNegative = (compareAbsolute(other) > 0);}else{// 都是正数:a - bif (*this < other){swap(a, b);resultNegative = true;}}// 执行减法string result;int borrow = 0;int i = a.length() - 1;int j = b.length() - 1;while (i >= 0){int digit1 = a[i] - '0' - borrow;int digit2 = j >= 0 ? b[j] - '0' : 0;if (digit1 < digit2){digit1 += 10;borrow = 1;}else{borrow = 0;}result.push_back((digit1 - digit2) + '0');i--;j--;}// 移除结果中的前导零while (result.length() > 1 && result.back() == '0'){result.pop_back();}reverse(result.begin(), result.end());SimpleBigInt res(result);res.negative = resultNegative;return res;}// 乘法SimpleBigInt operator*(const SimpleBigInt& other) const{if (num == "0" || other.num == "0"){return SimpleBigInt("0");}int len1 = num.length();int len2 = other.num.length();vector<int> result(len1 + len2, 0);// 从低位到高位相乘for (int i = len1 - 1; i >= 0; i--){for (int j = len2 - 1; j >= 0; j--){int mul = (num[i] - '0') * (other.num[j] - '0');int sum = mul + result[i + j + 1];result[i + j + 1] = sum % 10;result[i + j] += sum / 10;}}// 转换为字符串string strResult;for (int digit : result){if (!(strResult.empty() && digit == 0)){strResult.push_back(digit + '0');}}if (strResult.empty()) strResult = "0";SimpleBigInt res(strResult);res.negative = (negative != other.negative);return res;}// 除法(返回商和余数)pair<SimpleBigInt, SimpleBigInt> divide(const SimpleBigInt& divisor) const{if (divisor == SimpleBigInt("0")){throw runtime_error("Division by zero");}SimpleBigInt dividend = *this;dividend.negative = false;SimpleBigInt div = divisor;div.negative = false;if (dividend < div){return {SimpleBigInt("0"), *this};}string quotient;string current;for (char digit : dividend.num){current.push_back(digit);SimpleBigInt cur(current);int count = 0;while (cur >= div){cur = cur - div;count++;}quotient.push_back(count + '0');current = cur.num;if (current == "0") {current.clear();}}// 移除商的前导零size_t pos = quotient.find_first_not_of('0');if (pos == string::npos){quotient = "0";}else{quotient = quotient.substr(pos);}SimpleBigInt q(quotient);SimpleBigInt r(current.empty() ? "0" : current);q.negative = (negative != divisor.negative);r.negative = negative; // 余数符号与被除数相同return {q, r};}// 除法运算符(返回商)SimpleBigInt operator/(const SimpleBigInt& other) const{return divide(other).first;}// 取模运算符SimpleBigInt operator%(const SimpleBigInt& other) const{return divide(other).second;}// 快速幂取模(核心算法)static SimpleBigInt modPow(SimpleBigInt base, SimpleBigInt exponent, SimpleBigInt modulus){if (modulus == SimpleBigInt("1")) return SimpleBigInt("0");if (exponent == SimpleBigInt("0")) return SimpleBigInt("1");SimpleBigInt result("1");base = base % modulus;// 将指数转换为二进制字符串string binary;SimpleBigInt exp = exponent;while (exp > SimpleBigInt("0")){// 检查最低位pair<SimpleBigInt, SimpleBigInt> divResult = exp.divide(SimpleBigInt("2"));if (divResult.second == SimpleBigInt("1")){binary = "1" + binary;}else{binary = "0" + binary;}exp = divResult.first; // exp = exp / 2}// 快速幂算法for (char bit : binary){result = (result * result) % modulus;if (bit == '1'){result = (result * base) % modulus;}}return result;}static pair<SimpleBigInt, SimpleBigInt> extendedGcd(SimpleBigInt a, SimpleBigInt b){if (b == SimpleBigInt("0")){return {SimpleBigInt("1"), SimpleBigInt("0")};}pair<SimpleBigInt, SimpleBigInt> temp = extendedGcd(b, a % b);SimpleBigInt x1 = temp.first;SimpleBigInt y1 = temp.second;SimpleBigInt x = y1;SimpleBigInt y = x1 - (a / b) * y1;return {x, y};}// 模逆元static SimpleBigInt modInverse(SimpleBigInt a, SimpleBigInt m){pair<SimpleBigInt, SimpleBigInt> gcdResult = extendedGcd(a, m);SimpleBigInt x = gcdResult.first;SimpleBigInt y = gcdResult.second;// 检查是否有逆元 (gcd(a, m) 必须为1)SimpleBigInt gcd = a * x + m * y;if (gcd != SimpleBigInt("1")){return SimpleBigInt("-1"); // 无逆元}// 确保结果为正SimpleBigInt result = x % m;if (result.isNegative()){result = result + m;}return result;}};// ============ RSA 实现 ============namespace RSA{using BigInt = SimpleBigInt;struct RSAKey{BigInt n; // 模数BigInt e; // 公钥指数BigInt d; // 私钥指数};// Miller-Rabin 素性测试(简化版)bool isPrimeSimple(const BigInt& n, int k = 5){if (n == BigInt("2") || n == BigInt("3")) return true;if (n < BigInt("2") || n % BigInt("2") == BigInt("0")) return false;// 将 n-1 分解为 d * 2^sBigInt d = n - BigInt("1");int s = 0;while (d % BigInt("2") == BigInt("0")){d = d / BigInt("2");s++;}srand(time(nullptr));for (int i = 0; i < k; i++){// 随机选择基数 aBigInt a(to_string(2 + rand() % 100)); // 简化:使用小随机数if (a >= n - BigInt("1")){a = BigInt("2");}BigInt x = BigInt::modPow(a, d, n);if (x == BigInt("1") || x == n - BigInt("1")) {continue;}bool composite = true;for (int j = 0; j < s - 1; j++){x = (x * x) % n;if (x == n - BigInt("1")){composite = false;break;}}if (composite){return false;}}return true;}// 生成素数(简化版)BigInt generatePrimeSimple(int bits = 16){if (bits < 8) bits = 8;srand(time(nullptr));int maxAttempts = 1000;for (int attempt = 0; attempt < maxAttempts; attempt++){// 生成随机数string numStr = "1"; // 确保最高位是1for (int i = 1; i < bits - 1; i++){numStr += (rand() % 2) ? '1' : '0';}numStr += '1'; // 确保是奇数BigInt candidate(numStr);// 快速检查小素数vector<int> smallPrimes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};bool divisible = false;for (int prime : smallPrimes){if (candidate % BigInt(to_string(prime)) == BigInt("0")){divisible = true;break;}}if (divisible) continue;// 简化素性测试if (isPrimeSimple(candidate)){return candidate;}}// 如果没找到,返回一个已知的素数return BigInt("101");}// 生成RSA密钥对// 生成RSA密钥对(修复版)RSAKey generateKeyPair(int keySize = 64){RSAKey key;// 生成两个不同的素数BigInt p = generatePrimeSimple(keySize / 2);BigInt q = generatePrimeSimple(keySize / 2);while (q == p){q = generatePrimeSimple(keySize / 2);}// 计算 n = p * qkey.n = p * q;// 计算 φ(n) = (p-1)*(q-1)BigInt phi = (p - BigInt("1")) * (q - BigInt("1"));// 选择公钥指数 e(常用值)vector<int> eCandidates = {3, 5, 17, 257, 65537};bool found = false;for (int eVal : eCandidates){key.e = BigInt(to_string(eVal));// 修复:不使用结构化绑定pair<SimpleBigInt, SimpleBigInt> gcdResult = BigInt::extendedGcd(key.e, phi);SimpleBigInt gcd = gcdResult.first * key.e + gcdResult.second * phi;if (gcd == BigInt("1")){found = true;break;}}if (!found){// 尝试较小的奇数for (int eVal = 3; eVal < 100; eVal += 2){key.e = BigInt(to_string(eVal));// 修复:不使用结构化绑定pair<SimpleBigInt, SimpleBigInt> gcdResult = BigInt::extendedGcd(key.e, phi);SimpleBigInt gcd = gcdResult.first * key.e + gcdResult.second * phi;if (gcd == BigInt("1")){found = true;break;}}}if (!found){// 使用默认值key.e = BigInt("65537");}// 计算私钥指数 d = e^(-1) mod φ(n)key.d = BigInt::modInverse(key.e, phi);return key;}// 字符串编码为数字BigInt stringToNumber(const string& str){string encoded;for (char c : str){int ascii = static_cast<int>(c);stringstream ss;ss << setw(3) << setfill('0') << ascii;encoded += ss.str();}return BigInt(encoded);}// 数字解码为字符串string numberToString(const BigInt& num){string numStr = num.getNum();string decoded;// 补全到3的倍数while (numStr.length() % 3 != 0){numStr = "0" + numStr;}for (size_t i = 0; i < numStr.length(); i += 3){string triplet = numStr.substr(i, 3);int ascii = stoi(triplet);if (ascii >= 32 && ascii <= 126){ // 可打印字符decoded += static_cast<char>(ascii);}}return decoded;}// RSA加密BigInt rsaEncrypt(const BigInt& message, const BigInt& e, const BigInt& n){return BigInt::modPow(message, e, n);}// RSA解密BigInt rsaDecrypt(const BigInt& ciphertext, const BigInt& d, const BigInt& n){return BigInt::modPow(ciphertext, d, n);}// 字符串加密string encryptString(const string& plaintext, const BigInt& e, const BigInt& n){BigInt encoded = stringToNumber(plaintext);BigInt encrypted = rsaEncrypt(encoded, e, n);return encrypted.toString();}// 字符串解密string decryptString(const string& ciphertext, const BigInt& d, const BigInt& n){BigInt cipherNum(ciphertext);BigInt decrypted = rsaDecrypt(cipherNum, d, n);return numberToString(decrypted);}// 演示函数void demo(){cout << "\n=== 简单RSA演示 ===" << endl;cout << "注意:这是一个独立实现,不依赖外部库" << endl;// 生成密钥对cout << "\n1. 生成RSA密钥对..." << endl;RSAKey key = generateKeyPair(32);cout << "公钥 (n, e):" << endl;cout << " n = " << key.n.toString() << endl;cout << " e = " << key.e.toString() << endl;cout << "\n私钥 (n, d):" << endl;cout << " n = " << key.n.toString() << endl;cout << " d = " << key.d.toString() << endl;// 测试消息string testMessage = "HELLO";cout << "\n2. 测试加密/解密" << endl;cout << "原始消息: \"" << testMessage << "\"" << endl;// 加密string encrypted = encryptString(testMessage, key.e, key.n);cout << "加密后: " << encrypted << endl;// 解密string decrypted = decryptString(encrypted, key.d, key.n);cout << "解密后: \"" << decrypted << "\"" << endl;if (testMessage == decrypted){cout << "\n? RSA加解密成功!" << endl;}else{cout << "\n? RSA加解密失败!" << endl;}// 额外测试:验证数学运算cout << "\n3. 验证数学运算" << endl;cout << "测试: 5^3 mod 13" << endl;BigInt testResult = BigInt::modPow(BigInt("5"), BigInt("3"), BigInt("13"));729 行未改动全部展开89 行未改动909192939495969798406 行未改动全部展开505506507508509510511512513167 行未改动全部展开6816826836846856866876886896906916927 行未改动7007017027037047057067077087097107117126 行未改动71972072172272372472572672714 行未改动74274374474574674774874975075153 行未改动805806807808809810811812813359 行未改动全部展开117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512468 行未改动1255125612571258125912601261126212638 行未改动1272127312741275127612771278127912808 行未改动1289129012911292129312941295129612978 行未改动130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213737 行未改动138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314244 行未改动14291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147058 行未改动15291530153115321533153415351536153712 行未改动1550155115521553155415551556155715585 行未改动15641565156615671568156915701571157234 行未改动16071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816497 行未改动16571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316844 行未改动168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917204 行未改动17251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176613 行未改动17801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181513 行未改动1829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185111 行未改动1863186418651866186718681869187018717 行未改动187918801881188218831884188518861887188818891890189118921893189411 行未改动1906190719081909191019111912191319142 行未改动1917191819191920192119221923192419257 行未改动193319341935193619371938193919401941194219431944194519461947194819491950195119521953195422 行未改动19771978197919801981198219831984198519861987198819891990199119921993199419958 行未改动20042005200620072008200920102011201210 行未改动202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205623 行未改动20802081208220832084208520862087208820892090209120927 行未改动2100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212245 行未改动21682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012 行未改动2204220522062207220822092210221122122213221422152216221722182219222022212222222346 行未改动22702271227222732274227522762277227829 行未改动2308230923102311231223132314231523164 行未改动232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239312 行未改动24062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242973 行未改动25032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326443 行未改动2648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270047 行未改动27482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290034 行未改动2935293629372938293929402941294229432944294529462947294829492950295129522 行未改动295529562957295829592960296129622963296429652966296729682969297029714 行未改动29762977297829792980298129822983298429852986298729882989299029912992299323 行未改动30173018301930203021302230233024302517 行未改动30433044304530463047304830493050305121 行未改动3073307430753076307730783079308030816 行未改动308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114103 行未改动全部展开321832193220322132223223322432253226322732284 行未改动323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432554 行未改动3260326132623263326432653266326732685 行未改动327432753276327732783279328032813282328332843285328632873288266 行未改动全部展开35553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358731 行未改动36193620362136223623362436253626362713 行未改动36413642364336443645364636473648364918 行未改动36683669367036713672367336743675367636773678367936809 行未改动3690369136923693369436953696369736986 行未改动3705370637073708370937103711371237137 行未改动372137223723372437253726372737283729155 行未改动全部展开388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390925 行未改动39353936393739383939394039413942394328 行未改动39723973397439753976397739783979398038 行未改动40194020402140224023402440254026402730 行未改动40584059406040614062406340644065406626 行未改动4093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411858 行未改动417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841997 行未改动42074208420942104211421242134214421537 行未改动4253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842796 行未改动42864287428842894290429142924293429415 行未改动431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434016 行未改动4357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434 行未改动444844494450445144524453445444554456104 行未改动全部展开45614562456345644565456645674568456988 行未改动4658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747085 行未改动47144715471647174718471947204721472247234724472547264727472847294730473147324733293 行未改动全部展开502750285029503050315032503350345035503650375038503950405041504250435044504583 行未改动512951305131513251335134513551365137513851395140514151425143100 行未改动52445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353346 行未改动53415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454252 行未改动542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754982 行未改动5501550255035504550555065507550855094 行未改动551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855392 行未改动5542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855897 行未改动5597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156323 行未改动5636563756385639564056415642564356445645564656475648564956504 行未改动56555656565756585659566056615662566313 行未改动567756785679568056815682568356845685568656875688568956905691569256932 行未改动56965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574014 行未改动57555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577810 行未改动578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745 行未改动588058815882588358845885588658875888588958905891589258935894589558966 行未改动5903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360049 行未改动60146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360442 行未改动60476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610029 行未改动613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615717 行未改动617561766177617861796180618161826183618461856186618761886189619014 行未改动62056206620762086209621062116212621380 行未改动6294629562966297629862996300630163023 行未改动63066307630863096310631163126313631463155 行未改动6321632263236324632563266327632863296330633163326333633415 行未改动6350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638418 行未改动6403640464056406640764086409641064117 行未改动64196420642164226423642464256426642764286429643064316432643364346435643619 行未改动64566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650322 行未改动6526652765286529653065316532653365342 行未改动6537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466355 行未改动664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670484 行未改动67896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568168 行未改动6825682668276828682968306831683268335 行未改动6839684068416842684368446845684668473 行未改动685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969003 行未改动690469056906690769086909691069116912691369146915691669176918691969202 行未改动6923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469553 行未改动6959696069616962696369646965696669676968696969706971697269736974697547 行未改动7023702470257026702770287029703070317032703370347035703670377038703970407041704270436 行未改动7050705170527053705470557056705770583 行未改动70627063706470657066706770687069707010 行未改动708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371548 行未改动716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972305 行未改动7236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673972 行未改动7400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769519 行未改动77157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877396 行未改动774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784512 行未改动785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079614 行未改动796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592729 行未改动全部展开89 行未改动```cppstruct Save {string path; // 文件路径int errorlevel; // 错误代码// 方法void setpt(string s); // 设置路径void read_nol(); // 以文本模式打开读取void read_bin(); // 以二进制模式打开读取406 行未改动全部展开#### 文件日志```cppstruct logger {enum error_type { error=0, info=1, warn=2, debug=3 };void reset_logger(string path); // 初始化日志文件void report(string s, error_type tp); // 记录日志void stop(); // 停止日志};167 行未改动全部展开int main() {scg(RED, BLACK);say("Hello, World!", 50);scg(GREEN, BLACK);cout << "2 + 2 = " << PLS(2, 2) << endl;return 0;}```7 行未改动file.setpt("test.txt");file.save_nol();file.save_o << "Hello, File!" << endl;file.save_stop();if (fileok("test.txt")) {cout << "File created successfully!" << endl;}return 0;}```6 行未改动cout << "PI = " << PI << endl;cout << "sqrt(2) = " << getSqrtNt(2, 0.0001) << endl;cout << "5! = " << fac(5) << endl;cout << "Is 17 prime? " << isPrime(17) << endl;return 0;}```14 行未改动此指南涵盖了jtbg.h库的主要功能,具体使用时请参考源代码中的详细实现和注释。## 七、下载[ilanzou(持续更新)](https://www.ilanzou.com/s/83wNo2Vk)[ilanzou(2.9)](https://www.ilanzou.com/s/gE2nYqIi)## 八、源码```cpp#undef _WIN32_WINNT53 行未改动#pragma GCC optimize("O0")//你可以换成指令: -O0#endif#pragma cpp_std c++11//你可以换成指令: -std=gnu++11#pragma comment(lib, "winmm.lib")//你可以换成 -lwinmm#pragma comment(lib, "wininet.lib")359 行未改动全部展开}#endif#ifdef JTBG_HASHclass MD5{private:typedef unsigned int uint32;typedef unsigned long long uint64;struct Context{uint32 state[4];uint32 count[2];unsigned char buffer[64];};static void init(Context &ctx){ctx.count[0] = ctx.count[1] = 0;ctx.state[0] = 0x67452301;ctx.state[1] = 0xefcdab89;ctx.state[2] = 0x98badcfe;ctx.state[3] = 0x10325476;}static void update(Context &ctx, const unsigned char *input, size_t length){uint32 i, index, partLen;index = (uint32)((ctx.count[0] >> 3) & 0x3F);if ((ctx.count[0] += ((uint32)length << 3)) < ((uint32)length << 3))ctx.count[1]++;ctx.count[1] += (uint32)(length >> 29);partLen = 64 - index;if (length >= partLen){memcpy(&ctx.buffer[index], input, partLen);transform(ctx.state, ctx.buffer);for (i = partLen; i + 63 < length; i += 64)transform(ctx.state, &input[i]);index = 0;}else{i = 0;}memcpy(&ctx.buffer[index], &input[i], length - i);}static void final(unsigned char digest[16], Context &ctx){unsigned char padding[64] = {0x80};unsigned char bits[8];size_t index, padLen;encode(bits, ctx.count, 8);index = (uint32)((ctx.count[0] >> 3) & 0x3f);padLen = (index < 56) ? (56 - index) : (120 - index);update(ctx, padding, padLen);update(ctx, bits, 8);encode(digest, ctx.state, 16);}static void transform(uint32 state[4], const unsigned char block[64]){uint32 a = state[0], b = state[1], c = state[2], d = state[3], x[16];decode(x, block, 64);FF(a, b, c, d, x[0], 7, 0xd76aa478);FF(d, a, b, c, x[1], 12, 0xe8c7b756);FF(c, d, a, b, x[2], 17, 0x242070db);FF(b, c, d, a, x[3], 22, 0xc1bdceee);8 行未改动FF(a, b, c, d, x[12], 7, 0x6b901122);FF(d, a, b, c, x[13], 12, 0xfd987193);FF(c, d, a, b, x[14], 17, 0xa679438e);FF(b, c, d, a, x[15], 22, 0x49b40821);GG(a, b, c, d, x[1], 5, 0xf61e2562);GG(d, a, b, c, x[6], 9, 0xc040b340);GG(c, d, a, b, x[11], 14, 0x265e5a51);GG(b, c, d, a, x[0], 20, 0xe9b6c7aa);8 行未改动GG(a, b, c, d, x[13], 5, 0xa9e3e905);GG(d, a, b, c, x[2], 9, 0xfcefa3f8);GG(c, d, a, b, x[7], 14, 0x676f02d9);GG(b, c, d, a, x[12], 20, 0x8d2a4c8a);HH(a, b, c, d, x[5], 4, 0xfffa3942);HH(d, a, b, c, x[8], 11, 0x8771f681);HH(c, d, a, b, x[11], 16, 0x6d9d6122);HH(b, c, d, a, x[14], 23, 0xfde5380c);8 行未改动HH(a, b, c, d, x[9], 4, 0xd9d4d039);HH(d, a, b, c, x[12], 11, 0xe6db99e5);HH(c, d, a, b, x[15], 16, 0x1fa27cf8);HH(b, c, d, a, x[2], 23, 0xc4ac5665);II(a, b, c, d, x[0], 6, 0xf4292244);II(d, a, b, c, x[7], 10, 0x432aff97);II(c, d, a, b, x[14], 15, 0xab9423a7);II(b, c, d, a, x[5], 21, 0xfc93a039);8 行未改动II(a, b, c, d, x[4], 6, 0xf7537e82);II(d, a, b, c, x[11], 10, 0xbd3af235);II(c, d, a, b, x[2], 15, 0x2ad7d2bb);II(b, c, d, a, x[9], 21, 0xeb86d391);state[0] += a;state[1] += b;state[2] += c;state[3] += d;}static inline uint32 F(uint32 x, uint32 y, uint32 z) { return (x & y) | (~x & z); }static inline uint32 G(uint32 x, uint32 y, uint32 z) { return (x & z) | (y & ~z); }static inline uint32 H(uint32 x, uint32 y, uint32 z) { return x ^ y ^ z; }static inline uint32 I(uint32 x, uint32 y, uint32 z) { return y ^ (x | ~z); }static inline void FF(uint32 &a, uint32 b, uint32 c, uint32 d, uint32 x, uint32 s, uint32 t){a += F(b, c, d) + x + t;a = (a << s) | (a >> (32 - s));a += b;}static inline void GG(uint32 &a, uint32 b, uint32 c, uint32 d, uint32 x, uint32 s, uint32 t){a += G(b, c, d) + x + t;a = (a << s) | (a >> (32 - s));a += b;}static inline void HH(uint32 &a, uint32 b, uint32 c, uint32 d, uint32 x, uint32 s, uint32 t){a += H(b, c, d) + x + t;a = (a << s) | (a >> (32 - s));a += b;}static inline void II(uint32 &a, uint32 b, uint32 c, uint32 d, uint32 x, uint32 s, uint32 t){a += I(b, c, d) + x + t;a = (a << s) | (a >> (32 - s));a += b;}static void encode(unsigned char *output, const uint32 *input, size_t length){for (size_t i = 0, j = 0; j < length; i++, j += 4){output[j] = (unsigned char)(input[i] & 0xFF);output[j + 1] = (unsigned char)((input[i] >> 8) & 0xFF);output[j + 2] = (unsigned char)((input[i] >> 16) & 0xFF);output[j + 3] = (unsigned char)((input[i] >> 24) & 0xFF);}}static void decode(uint32 *output, const unsigned char *input, size_t length){for (size_t i = 0, j = 0; j < length; i++, j += 4)output[i] = ((uint32)input[j]) | (((uint32)input[j + 1]) << 8) |(((uint32)input[j + 2]) << 16) | (((uint32)input[j + 3]) << 24);}public:static string hash(const string &input){Context ctx;init(ctx);update(ctx, (const unsigned char*)input.c_str(), input.length());7 行未改动}};//MD5::hash(str)unsigned long long pHash(const string& s){const unsigned long long base = 911382629ULL;const unsigned long long mod = 1000000000000000003ULL;unsigned long long hashValue = 0;// 使用传统for循环兼容C++98for (size_t i = 0; i < s.size(); ++i){char c = s[i];hashValue = (hashValue * base + static_cast<unsigned long long>(c)) % mod;}return hashValue;}struct StringHash{static const unsigned long long base = 911382629ULL;static const unsigned long long mod = 1000000000000000003ULL;vector<unsigned long long> hash;vector<unsigned long long> power;StringHash(const string& s){int n = s.size();hash.resize(n + 1);power.resize(n + 1);power[0] = 1;for (int i = 0; i < n; ++i) {hash[i+1] = (hash[i] * base + static_cast<unsigned long long>(s[i])) % mod;power[i+1] = (power[i] * base) % mod;}}// 获取子串s[l..r]的哈希值(0-based,包含l和r)unsigned long long getHash(int l, int r){int len = r - l + 1;unsigned long long res = (hash[r+1] - hash[l] * power[len]) % mod;if(false) return res+mod;4 行未改动//StringHash strHash(str);//cout << "前缀哈希完整字符串: " << strHash.getHash(0, str.size()-1) << endl;//cout << "子串哈希(0-4): " << strHash.getHash(0, 4) << " (对应\"Hello\")" << endl;size_t Hash(const string& s){size_t hashVal = 0;for (size_t i = 0; i < s.size(); ++i){// 简单的哈希组合算法hashVal = hashVal * 31 + static_cast<size_t>(s[i]);}return hashVal;}string FileMD5(string path){ifstream file(path,ios::in|ios::binary);if (!file.is_open()){return "";}string fileContent;file.seekg(0,ios::end);size_t fileSize = static_cast<size_t>(file.tellg());file.seekg(0,ios::beg);fileContent.reserve(fileSize);fileContent.assign(istreambuf_iterator<char>(file),istreambuf_iterator<char>());if (!file && !file.eof()){return "";}return MD5::hash(fileContent);}#endif#ifdef JTBG_FILEbool Isfileext(const string& filePath){ifstream file(filePath, ios::in | ios::binary);bool exists = file.good();file.close();58 行未改动inline void read((bool)*f{bool})//检测文件读写是否bool fileok(const string &filename){ifstream file(filename);return file.good();}12 行未改动}return ;}void paused(string s){cout<<s<<endl;system("pause > nul");return ;5 行未改动exit(num);return num;}enum Color{BLACK = 0,BLUE = 1,GREEN = 2,34 行未改动return ;}//控制台光标位置控制void setcursor(int x,int y){COORD coord;coord.X = x;coord.Y = y;SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);}//清除控制台指定区域内容void clearCA(int x, int y, int width, int height){for(int i=0;i<height;i++){setcursor(x, y + i);cout << string(width, ' ');}}//隐藏/显示控制台光标void setCVis(bool visible){CONSOLE_CURSOR_INFO cursorInfo = {1, visible};SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursorInfo);}//获取控制台尺寸void getCSize(int &width,int &height){CONSOLE_SCREEN_BUFFER_INFO csbi;GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);width = csbi.srWindow.Right - csbi.srWindow.Left + 1;height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;}void flushed(){cin.ignore(numeric_limits<streamsize>::max(), '\n');cin.clear();return ;7 行未改动return a+rand()%(b+1);}//生成指定长度的随机字符串string randS(int length){const string chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";string result;for (int i = 0; i < length; ++i) {result += chars[rand() % chars.size()];}return result;}double random(double min, double max){return min + (max - min) * (rand() / (double)RAND_MAX);}#endif#ifdef JTBG_STRING/** @brief 在字符串中查找匹配指定模式的位置** @param s 要搜索的目标字符串* @param pattern 匹配模式,支持通配符:* %d - 匹配整数* %Nd - 匹配宽度为N的整数(必须正好N位数字)4 行未改动* %c - 匹配单个字符* %Nc - 匹配N个字符* %% - 匹配百分号字符* 普通字符 - 直接匹配对应字符** @return int 返回匹配开始的索引位置,如果未找到匹配则返回-1** @example* find_in_string("123abc", "%d%s") // 返回0,匹配"123abc"* find_in_string("hello 123", "%s %d") // 返回0,匹配"hello 123"* find_in_string("abc123", "%3s%d") // 返回0,匹配"abc123"* find_in_string("hello world", "%k") // 返回0,匹配整个字符串* find_in_string("5[hi]", "%d[%2s]") // 返回0,匹配"5[hi]"** @note 模式匹配是贪婪的,会尝试从每个位置开始匹配*/int find_in_string(const string& s, const string& pattern){int s_len = s.length();int p_len = pattern.length();// 尝试从每个位置开始匹配for (int start = 0; start <= s_len; ++start){int i = start; // 目标字符串的当前位置int j = 0; // 模式的当前位置bool matched = true;// 遍历模式字符串while (j < p_len && i <= s_len){// 检查是否是通配符4 行未改动{matched = false;break;}j++; // 跳过%// 解析宽度限定符(如果有)int width = 0;bool has_width = false;while (j < p_len && isdigit(pattern[j])){width = width * 10 + (pattern[j] - '0');j++;has_width = true;}// 确保有说明符if (j >= p_len){matched = false;break;}char specifier = pattern[j];j++; // 跳过说明符// 根据说明符处理不同类型的匹配switch (specifier){case 'd': // 匹配整数if (i >= s_len){matched = false;break;}if (has_width){// 固定宽度整数:必须正好匹配width位数字for (int k = 0; k < width; k++)13 行未改动{matched = false;break;}// 可选符号if (s[i] == '-' || s[i] == '+'){i++;}// 匹配一个或多个数字if (i >= s_len || !isdigit(s[i])){matched = false;break;}while (i < s_len && isdigit(s[i])){i++;}}break;case 's': // 匹配非空白字符串if (i >= s_len){matched = false;break;}if (has_width){// 固定宽度字符串:匹配width个任意字符(包括空白符)for (int k = 0; k < width; k++)13 行未改动{matched = false;break;}while (i < s_len && !isspace(s[i])){i++;}}break;case 'k': // 匹配任意字符串(可包含空白符)if (i >= s_len){matched = false;break;}if (has_width){// 固定宽度:匹配width个任意字符for (int k = 0; k < width; k++)11 行未改动// 变长:匹配到字符串结束或遇到模式中的下一个字符// 这里我们采用贪婪匹配,直到字符串结束// 实际的停止条件会在外层循环中处理int next_char = (j < p_len) ? pattern[j] : -1;// 如果没有下一个字符,匹配到字符串结束if (next_char == -1){i = s_len;7 行未改动}}}break;case 'c': // 匹配字符if (i >= s_len){matched = false;break;}if (has_width){// 固定宽度:匹配width个字符for (int k = 0; k < width; k++)11 行未改动// 单个字符i++;}break;case '%': // 匹配百分号if (i >= s_len || s[i] != '%'){matched = false;2 行未改动{i++;}break;default:matched = false;}}7 行未改动}i++;j++;}if (!matched){break;}}// 如果模式完全匹配且目标字符串也匹配完毕if (matched && j == p_len){return start;}}return -1; // 未找到匹配}template<typename T>22 行未改动{int m = s1.length();int n = s2.length();vector<vector<int>> dp(m + 1, vector<int>(n + 1));for (int i = 0; i <= m; i++){dp[i][0] = i;}for (int j = 0; j <= n; j++){dp[0][j] = j;}for (int i = 1; i <= m; i++){for (int j = 1; j <= n; j++){8 行未改动dp[i - 1][j - 1] + 1});}}}return dp[m][n];}template<typename T>10 行未改动if (s1.empty() && s2.empty()){return 100;}int maxLen = max(s1.length(), s2.length());if (maxLen == 0){return 0;}int distance = editDistance(s1, s2);return (int)((1.0 - (double)distance / maxLen) * 100.0);}//检查字符串是否为数字(整数或小数)bool isNumber(const string& str){if (str.empty()) return false;size_t start = 0;if (str[0] == '+' || str[0] == '-') start = 1;bool hasDot = false;for (size_t i = start; i < str.size(); ++i){if (str[i] == '.'){if (hasDot) return false;hasDot = true;}else if (!isdigit(str[i])){return false;}}23 行未改动}return ;}void Testsuper(string &s){if (s.empty()) return;s[0] = toupper(s[0]);for (size_t i = 1; i < s.size();i++){s[i]=tolower(s[i]);}}7 行未改动{if(t!=-1){t*=100;while(t--){if (_kbhit()){int key = _getch();return key;}}return -1;}else{while(1){if (_kbhit()){int key = _getch();return key;}45 行未改动{private:using Clock = chrono::high_resolution_clock;using TimePoint = chrono::time_point<Clock>;TimePoint start_;TimePoint pause_;bool isRunning_;chrono::duration<double> elapsed_;public:Timer() : isRunning_(false), elapsed_(0) {}void starttick(){if (!isRunning_){start_ = Clock::now();isRunning_ = true;}}void pausetick(){if (isRunning_){pause_ = Clock::now();elapsed_ += pause_ - start_;isRunning_ = false;}}void resettick(){isRunning_ = false;elapsed_ = chrono::duration<double>(0);}2 行未改动isRunning_ = false;elapsed_ = chrono::duration<double>(t);return ;}double timesec()const{if (isRunning_){auto now = Clock::now();return (elapsed_ + (now - start_)).count();}return elapsed_.count();}double timemst()const{return timesec() * 1000.0;}};46 行未改动}}string getArchName(int archCode){switch (archCode){case SX64: return "x64 (AMD64)";case SX86: return "x86 (Intel)";case SARM32: return "ARM (32-bit)";29 行未改动{char szPath[MAX_PATH];GetModuleFileName(NULL, szPath, MAX_PATH);SHELLEXECUTEINFO sei;ZeroMemory(&sei,sizeof(sei));sei.cbSize = sizeof(sei);sei.lpVerb = "runas";sei.lpFile = szPath;sei.hwnd = NULL;4 行未改动bool AddToCurrentUserStartup(const string& appName, const string& appPath){HKEY hKey;LONG result;// 使用 RegOpenKeyExA 和 RegSetValueExA (ANSI 版本)result = RegOpenKeyExA(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",0,KEY_WRITE,&hKey);if (result != ERROR_SUCCESS){return false;}// 如果路径包含空格,用引号包围string finalPath = appPath;if (appPath.find(' ') != string::npos && appPath[0] != '\"'){finalPath = "\"" + appPath + "\"";}result = RegSetValueExA(hKey,appName.c_str(),0,REG_SZ,(const BYTE*)finalPath.c_str(),finalPath.size() + 1);RegCloseKey(hKey);return (result == ERROR_SUCCESS);}bool isRun(const char* processName){HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);if (hSnapshot == INVALID_HANDLE_VALUE) return true;PROCESSENTRY32 pe32;pe32.dwSize = sizeof(PROCESSENTRY32);if (Process32First(hSnapshot, &pe32)){do{if (strcmp(pe32.szExeFile, processName) == 0){CloseHandle(hSnapshot);return true;}}while (Process32Next(hSnapshot, &pe32));}CloseHandle(hSnapshot);return false;}void Hide(){HWND hwnd = GetForegroundWindow(); // 获取当前窗口句柄if (hwnd) ShowWindow(hwnd, SW_HIDE); // 隐藏窗口}void Show(){HWND hwnd = GetForegroundWindow(); // 获取当前窗口句柄if (hwnd) ShowWindow(hwnd, SW_SHOW); // 隐藏窗口}12 行未改动return static_cast<long long>(file.tellg());}//延迟函数(高精度ms)void msSleep(int milliseconds){auto start = chrono::high_resolution_clock::now();while (chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() < milliseconds);}//计算文件夹内文件数量(仅统计一级目录)int getFileCountInDir(const string& dirPath){int count = 0;WIN32_FIND_DATA findData;HANDLE hFind = FindFirstFile((dirPath + "\\*").c_str(), &findData);if (hFind == INVALID_HANDLE_VALUE) return -1;do{if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)){count++; // 只统计文件,不统计文件夹}} while (FindNextFile(hFind, &findData) != 0);73 行未改动}#endif#ifdef JTBG_DECANDENCstring xorFile(const string& filePath,const string& key){if (key.empty()){return "";}ifstream file(filePath.c_str(), ios::in | ios::binary);if (!file.is_open()){return "";}string fileContent;char buffer[4096];while (file.read(buffer, sizeof(buffer))){fileContent.append(buffer, sizeof(buffer));}fileContent.append(buffer, file.gcount());const size_t keyLen = key.size();size_t keyIndex = 0;for (string::iterator it = fileContent.begin(); it != fileContent.end(); ++it){*it = static_cast<char>(static_cast<uint8_t>(*it) ^ static_cast<uint8_t>(key[keyIndex]));keyIndex = (keyIndex + 1) % keyLen;}return fileContent;}void xortoFile(const string& filePath,const string& key){if (key.empty()){return ;}ifstream file(filePath.c_str(),ios::in | ios::binary);if (!file.is_open()){return ;}string fileContent;char buffer[4096];while (file.read(buffer, sizeof(buffer))){fileContent.append(buffer, sizeof(buffer));}fileContent.append(buffer, file.gcount());file.close();const size_t keyLen = key.size();size_t keyIndex = 0;for (string::iterator it = fileContent.begin(); it != fileContent.end(); ++it){*it = static_cast<char>(static_cast<uint8_t>(*it) ^ static_cast<uint8_t>(key[keyIndex]));keyIndex = (keyIndex + 1) % keyLen;}ofstream outFile(filePath.c_str(), ios::out | ios::binary | ios::trunc);if (outFile.is_open()){outFile.write(fileContent.data(), fileContent.size());outFile.close();}}void caesarFile(const string& filePath,int shift){shift %= 256;if (shift < 0){shift += 256;}ifstream file(filePath.c_str(), ios::in | ios::binary);if (!file.is_open()){return ;}string fileContent;char buffer[4096];while (file.read(buffer, sizeof(buffer))){fileContent.append(buffer, sizeof(buffer));}fileContent.append(buffer, file.gcount());file.close();for(string::iterator it = fileContent.begin(); it != fileContent.end();it++){*it = static_cast<char>((static_cast<uint8_t>(*it) + shift) % 256);}ofstream outFile(filePath.c_str(), ios::out | ios::binary | ios::trunc);if (outFile.is_open()){outFile.write(fileContent.data(), fileContent.size());outFile.close();}}//加void FileCEnc(const string& filePath, int shift){caesarFile(filePath, shift);}//解void FileCDec(const string& filePath, int shift){caesarFile(filePath, 256 - (shift % 256));}//加密string CEnc(const string& input, int shift){shift %= 256;if (shift < 0){shift += 256;}string result = input;const size_t len = result.size();for (size_t i = 0; i < len; ++i){result[i] = static_cast<char>((static_cast<uint8_t>(result[i]) + shift) % 256);}return result;}//解密string CDec(const string& input, int shift){shift %= 256;if (shift < 0){shift += 256;}return CEnc(input, 256 - shift);}//xor加/解密string xorpass(const string &str, const string &key){string result = str;size_t keyLen = key.size();if (keyLen == 0) return result;3 行未改动}return result;}string base64up(const string &str,const string &base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"){string result;int val = 0, valBits = 0;for (unsigned char c : str){val = (val << 8) + c;valBits += 8;while (valBits >= 6){result += base64Chars[(val >> (valBits - 6)) & 0x3F];valBits -= 6;}}if (valBits > 0){val <<= (6 - valBits);result += base64Chars[val & 0x3F];}while (result.size() % 4 != 0){result += '=';}return result;}string base64dec(const string &str,const string base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"){string result;vector<int> val(4, -1);for (size_t i = 0; i < str.size(); ++i){char c = str[i];if (c == '=') break;size_t pos = base64Chars.find(c);if (pos == string::npos) continue;val[i % 4] = pos;if (i % 4 == 3){result += (val[0] << 2) + ((val[1] >> 4) & 0x3);if (val[2] != -1){result += ((val[1] << 4) & 0xF0) + ((val[2] >> 2) & 0xF);}if (val[3] != -1){result += ((val[2] << 6) & 0xC0) + val[3];}val.assign(4, -1);47 行未改动#define ftop(a,b) NumbertoPercent((a),(b))inline double getSqrtNt(double n,double t){if (n < 0){return NAN;}if (t <= 0){return NAN;}if (n == 0) return 0;double xn = n / 2.0;double xn1 = 0.0;const int MAX_ITER = 1000;int iterCount = 0;do{xn1 = xn - (xn * xn - n) / (2 * xn);if (fabs(xn1 - xn) < t){break;}xn = xn1;iterCount++;} while (iterCount < MAX_ITER);if (iterCount >= MAX_ITER){return NAN;}return xn1;}//角度转弧度inline double toRadians(double degrees){return degrees * DEG_TO_RAD;}// 弧度转角度inline double toDegrees(double radians){return radians * RAD_TO_DEG;}// 计算阶乘inline long long fac(int n){if(n<0) return -1;long long result = 1;for (int i = 2; i <= n; ++i){result *= i;}return result;}inline double qpow(double base, int exponent){if (exponent==0) return 1.0;if (base==0) return 0.0;bool isNegative = exponent < 0;unsigned int absExponent = static_cast<unsigned int>(isNegative ? -exponent : exponent);double result = 1.0;double current = base;while (absExponent > 0){if (absExponent % 2 == 1){result *= current;}current *= current;absExponent /= 2;}return isNegative ? 1.0 / result : result;}inline long long ipow(long long base, int exponent){if (exponent == 0) return 1;if (base == 0) return 0;bool isNegative = false;unsigned int absExp;if (exponent < 0){isNegative = true;absExp = static_cast<unsigned int>(-exponent);}else{absExp = static_cast<unsigned int>(exponent);}long long result = 1;long long current = base;while (absExp > 0){if (absExp & 1){result *= current;}current *= current;absExp >>= 1;}return isNegative ? (result == 0 ? 0 : 1) : result;}inline long long GetA(int a, int b){if(a < 0 || b < 0 || a < b){return -1;}if (b == 0){return 1;}long long result = 1;for (int i = 0; i < b; ++i){result *= (a - i);if (result < 0){return -1;}}return result;}inline long long GetC(int a, int b){if (a < 0 || b < 0 || a < b){return -1;}if (b == 0 || a == b){return 1;}b = min(b, a - b);long long result = 1;for (int i = 1; i <= b; ++i){result = result * (a - b + i) / i;if (result < 0){return -1;}}34 行未改动int sqrt_to = static_cast<int>(sqrt(to));for (int i = 2; i <= sqrt_to; ++i){if (is_prime[i]){for (int j = i * i; j <= to; j += i){is_prime[j] = false;}}}for (int num = from; num <= to; ++num){if (is_prime[num]){primes.push_back(num);}}2 行未改动inline vector<int> MakePrimelist_OLaShai(int from, int to){vector<int> primes;if (from > to || to < 2){return primes;}from=max(from, 2);vector<bool> is_prime(to + 1, true);is_prime[0] = is_prime[1] = false;vector<int> all_primes;for(int i = 2; i <= to; ++i){if (is_prime[i]){all_primes.push_back(i);4 行未改动{break;}is_prime[i * p] = false;if (i % p == 0){break;}}}for(int j=0;j<int(all_primes.size());++j){int p = all_primes[j];if (p >= from && p <= to){primes.push_back(p);}}23 行未改动}}vector<int> primes;from = max(from, 2);for (int p : cache_all_primes){if (p >= from && p <= to) primes.push_back(p);}return primes;17 行未改动shift++;}while ((a & 1) == 0)a >>= 1;do{while ((b & 1) == 0)b >>= 1;if (a < b)21 行未改动shift++;}while ((a & 1) == 0)a >>= 1;do{while ((b & 1) == 0)b >>= 1;if (a < b)6 行未改动inline long long jtbg_lcm(long long a, long long b, bool usesystem = 0){if (a == 0 || b == 0) return 0;long long gcd_val = jtbg_gcd(a, b, usesystem);if (gcd_val == 0) return 0;// lcm(a, b) = |a * b| / gcd(a, b)return llabs(a / gcd_val * b);}inline int jtbg_lcm(int a, int b, bool usesystem = 0){if (a == 0 || b == 0) return 0;int gcd_val = jtbg_gcd(a, b, usesystem);if (gcd_val == 0) return 0;// lcm(a, b) = |a * b| / gcd(a, b)return abs(a / gcd_val * b);}inline long long jtbg_lcm_multi(const vector<long long>& numbers, bool usesystem = 0){if (numbers.empty()) return 0;long long result = numbers[0];for (size_t i = 1; i < numbers.size(); ++i) {result = jtbg_lcm(result, numbers[i], usesystem);if (result == 0) break;103 行未改动全部展开{if (n < 0) return -1;if (n == 0) return 0;if (n == 1) return 1;long long a = 0, b = 1;for (int i = 2; i <= n; ++i){long long temp = a + b;a = b;b = temp;4 行未改动// 判断是否为斐波那契数inline bool jtbg_isFibonacci(int n){if (n < 0) return false;// 一个数是斐波那契数当且仅当 5*n^2+4 或 5*n^2-4 是完全平方数int check1 = 5 * n * n + 4;int check2 = 5 * n * n - 4;return jtbg_isPerfectSquare(check1) || jtbg_isPerfectSquare(check2);}// 计算数字的位数inline int jtbg_countDigits(long long n){if (n == 0) return 1;int count = 0;n = llabs(n);while (n > 0){n /= 10;count++;}4 行未改动inline int jtbg_digitSum(long long n){int sum = 0;n = llabs(n);while (n > 0){sum += n % 10;n /= 10;}5 行未改动{long long reversed = 0;bool negative = n < 0;n = llabs(n);while (n > 0){reversed = reversed * 10 + n % 10;n /= 10;}return negative ? -reversed : reversed;}// 判断回文数266 行未改动全部展开};long long gcd_val = gcd(a, b);a /= gcd_val;b /= gcd_val;while (b % 2 == 0){b /= 2;}while (b % 5 == 0){b /= 5;}if (b == 1){return 0;}long long phi_b = euler_phi(b);vector<long long> divisors = get_divisors(phi_b);for (long long k : divisors){if (quick_pow(10, k, b) == 1){return k;}}return -1;}inline long long int_to_long_long(int i)31 行未改动inline int jtbg_divcnt(int n){if (n <= 0) return 0;if (n == 1) return 1;int cnt = 1;int tmp = n;for (int i = 2; i * i <= tmp; i++){13 行未改动inline int jtbg_divsum(int n){if (n <= 0) return 0;if (n == 1) return 1;int sum = 1;int tmp = n;for (int i = 2; i * i <= tmp; i++){18 行未改动inline long long jtbg_crt(vector<long long> rem, vector<long long> mod){if (rem.size() != mod.size()) return -1;int k = rem.size();long long x = 0;long long M = 1;for (int i = 0; i < k; i++) M *= mod[i];for (int i = 0; i < k; i++){long long Mi = M / mod[i];long long inv = jtbg_modinv(Mi, mod[i]);9 行未改动inline long long jtbg_perm(long long n, long long k){if (n < 0 || k < 0 || k > n) return 0;if (k == 0) return 1;long long res = 1;for (long long i = 0; i < k; i++){if (res > LLONG_MAX / (n - i)) return -1;6 行未改动inline long long jtbg_comb(long long n, long long k){if (n < 0 || k < 0 || k > n) return 0;if (k == 0 || k == n) return 1;if (k > n - k) k = n - k;long long res = 1;for (long long i = 1; i <= k; i++){7 行未改动inline long long jtbg_catalan(int n){if (n < 0) return 0;if (n == 0) return 1;long long res = 1;for (int i = 1; i <= n; i++){res = res * (4 * i - 2) / (i + 1);155 行未改动全部展开inline double jtbg_root_bisect(double (*f)(double), double a, double b, double eps = 1e-10, int maxit = 1000){double fa = f(a);double fb = f(b);if (fa * fb > 0) return NAN; // 同号,区间内可能无根// 确保 fa < 0 < fbif (fa > 0){swap(a, b);swap(fa, fb);}for (int i = 0; i < maxit; i++){double mid = (a + b) / 2;double fm = f(mid);if (fabs(fm) < eps || (b - a) < eps) return mid;if (fm < 0){a = mid;fa = fm;25 行未改动double a3 = 1.421413741;double a4 = -1.453152027;double a5 = 1.061405429;double p = 0.3275911;int sign = (x < 0) ? -1 : 1;x = fabs(x);double t = 1.0 / (1.0 + p * x);double y = 1.0 - (((((a5 * t + a4) * t) + a3) * t + a2) * t + a1) * t * exp(-x * x);28 行未改动inline bool jtbg_mat2_inv(double m[2][2], double inv[2][2]){double det = jtbg_mat2_det(m);if (fabs(det) < 1e-10) return false;double inv_det = 1.0 / det;inv[0][0] = m[1][1] * inv_det;inv[0][1] = -m[0][1] * inv_det;inv[1][0] = -m[1][0] * inv_det;38 行未改动inline bool jtbg_vec_norm(double v[], int n){double len = jtbg_vec_len(v, n);if (len < 1e-10) return false;for (int i = 0; i < n; i++){v[i] /= len;}30 行未改动inline Complex jtbg_cdiv(Complex a, Complex b){double denom = b.re*b.re + b.im*b.im;if (fabs(denom) < 1e-10) return Complex(NAN, NAN);return Complex((a.re*b.re + a.im*b.im)/denom,(a.im*b.re - a.re*b.im)/denom);}// 复数模长26 行未改动// 复数幂 (a+bi)^ninline Complex jtbg_cpow(Complex c, int n){if (n == 0) return Complex(1, 0);Complex result(1, 0);Complex base = c;bool neg = false;if (n < 0){n = -n;neg = true;}while (n > 0){if (n & 1) result = jtbg_cmul(result, base);base = jtbg_cmul(base, base);n >>= 1;}if (neg){double denom = result.re*result.re + result.im*result.im;if (fabs(denom) < 1e-10) return Complex(NAN, NAN);58 行未改动inline double jtbg_rand_norm(double mu, double sigma){static bool hasSpare = false;static double spare;if (hasSpare){hasSpare = false;return mu + sigma * spare;}double u, v, s;do{u = (rand() / (RAND_MAX + 1.0)) * 2.0 - 1.0;v = (rand() / (RAND_MAX + 1.0)) * 2.0 - 1.0;s = u*u + v*v;} while (s >= 1.0 || s == 0.0);s = sqrt(-2.0 * log(s) / s);spare = v * s;hasSpare = true;return mu + sigma * u * s;7 行未改动return a + (b - a) * t;}// 双线性插值inline double jtbg_bilerp(double q11, double q12, double q21, double q22,double x, double y){double r1 = jtbg_lerp(q11, q21, x);double r2 = jtbg_lerp(q12, q22, x);37 行未改动{out[0] = in[0];return;}Complex* even = new Complex[n/2];Complex* odd = new Complex[n/2];Complex* even_fft = new Complex[n/2];Complex* odd_fft = new Complex[n/2];for (int i = 0; i < n/2; i++){even[i] = in[2*i];odd[i] = in[2*i + 1];}jtbg_fft(even, even_fft, n/2, inverse);jtbg_fft(odd, odd_fft, n/2, inverse);double angle = (inverse ? 2 : -2) * PI / n;Complex w_n(cos(angle), sin(angle));Complex w(1, 0);for (int k = 0; k < n/2; k++){Complex temp = jtbg_cmul(w, odd_fft[k]);out[k] = jtbg_cadd(even_fft[k], temp);6 行未改动out[k + n/2].im /= 2;}w = jtbg_cmul(w, w_n);}delete[] even;delete[] odd;delete[] even_fft;delete[] odd_fft;15 行未改动//===================================== 优化算法 =====================================// 梯度下降inline double jtbg_grad_desc(double (*f)(double), double x0,double lr = 0.01, int iter = 1000){double x = x0;double h = 1e-5;for (int i = 0; i < iter; i++){double grad = (f(x+h) - f(x-h)) / (2*h);x = x - lr * grad;}return x;}// 黄金分割搜索(求最小值)inline double jtbg_golden_search(double (*f)(double),double a, double b,double tol = 1e-7){const double phi = (sqrt(5) - 1) / 2;double c = b - phi * (b - a);double d = a + phi * (b - a);while (fabs(c - d) > tol){if (f(c) < f(d)){16 行未改动// 十进制转二进制字符串inline string jtbg_dec2bin(long long n){if (n == 0) return "0";string result;bool neg = false;if (n < 0){neg = true;n = -n;}while (n > 0){result = char('0' + (n & 1)) + result;n >>= 1;}if (neg) result = "-" + result;return result;}// 二进制字符串转十进制inline long long jtbg_bin2dec(string s){long long result = 0;bool neg = false;if (s[0] == '-'){neg = true;s = s.substr(1);}for (char c : s){result <<= 1;if (c == '1') result |= 1;else if (c != '0') return 0;}return neg ? -result : result;}// 十进制转十六进制inline string jtbg_dec2hex(long long n){if (n == 0) return "0";string result;bool neg = false;const char hex_chars[] = "0123456789ABCDEF";if (n < 0){neg = true;n = -n;}while (n > 0){result = hex_chars[n & 0xF] + result;n >>= 4;}if (neg) result = "-" + result;return result;}// 十六进制转十进制inline long long jtbg_hex2dec(string s){long long result = 0;bool neg = false;if (s[0] == '-'){neg = true;s = s.substr(1);}for (char c : s){result <<= 4;if (c >= '0' && c <= '9')4 行未改动result |= (c - 'a' + 10);elsereturn 0;}return neg ? -result : result;}//===================================== 位运算扩展 =====================================104 行未改动全部展开#define JTBG_QUIK_ENDL '\n'#define jtdl JTBG_QUIK_ENDL#define syst system("cls")#define sys(x) system(x)#define noy_pause() system("pause > nul")#define pause() system("pause")#define to_int(x) atoi(x.c_str()) // 转换为int类型#define to_long(x) stol(x) // 转换为long类型#define to_double(x) stod(x) // 转换为double类型88 行未改动};#endif#ifdef JTBG_LUHNstring prepluhn(const string& input){string result;for(int i=0;i<int(input.size());i++){char c=input[i];if (isdigit(c)){result+=c;}}return result;}int toluhn(const string& num){string number=prepluhn(num);int sum = 0;bool doubleFlag = false;string reversed = number;reverse(reversed.begin(), reversed.end());for(char c : reversed){if (!isdigit(c)){return -1;}int digit = c - '0';if (doubleFlag){digit *= 2;if (digit > 9){digit -= 9;}}sum += digit;doubleFlag = !doubleFlag;}return (10 - (sum % 10)) % 10;}bool visluhn(const string& fb){string fullNumber=prepluhn(fb);if (fullNumber.empty()) return false;string mainPart = fullNumber.substr(0, fullNumber.size() - 1);5 行未改动}#endif#ifdef JTBG_WEBbool Iswebok(){// INTERNET_CONNECTION_MODEM: 调制解调器// INTERNET_CONNECTION_LAN: 局域网// INTERNET_CONNECTION_WWAN: 移动网络(4G/5G)DWORD flags = 0;bool result = InternetGetConnectedState(&flags, 0);if (result){if (flags & INTERNET_CONNECTION_LAN) return 1;//局域网else if (flags & INTERNET_CONNECTION_MODEM) return 2;//调制解调器else return 3;//其他}else return 0;}#endif293 行未改动全部展开string cc_key_j= stdcc.ini_get_vol("key","cc_code");string end_time_j= stdcc.ini_get_vol("cc","end_time");string end_time_key_j= stdcc.ini_get_vol("key","end_time");string ccluhn_j=stdcc.ini_get_vol("cc","luhn");string key=stdcc.ini_get_vol("password","xor");string per=xorpass(per_j,key);string per_key=xorpass(per_key_j,key);string cc=xorpass(cc_j,key);string cc_key=xorpass(cc_key_j,key);string end_time=xorpass(end_time_j,key);string end_time_key=xorpass(end_time_key_j,key);string ccluhn=xorpass(ccluhn_j,key);if(MD5::hash(per)!=per_key) return CC_CHECK_BAD;else if(MD5::hash(cc)!=cc_key) return CC_CHECK_BAD;else if(MD5::hash(end_time)!=end_time_key) return CC_CHECK_BAD;if(int(end_time.size())==8)83 行未改动//GNUSenum class Gnuver{V2,V3,LGPL_V3,CHINESEGNU};string GetGnulicens(Gnuver version = Gnuver::V3){switch (version){case Gnuver::CHINESEGNU:return R"(GNU通用公共许可协议第二版,1991年6月100 行未改动)";case Gnuver::V2:return R"(GNU GENERAL PUBLIC LICENSEVersion 2, June 1991Copyright (C) 1989, 1991 Free Software Foundation, Inc.59 Temple Place - Suite 330, Boston, MA 02111-1307, USAEveryone is permitted to copy and distribute verbatim copiesof this license document, but changing it is not allowed.PreambleThe licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.The precise terms and conditions for copying, distribution and modification follow.TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.NO WARRANTY11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.END OF TERMS AND CONDITIONSHow to Apply These Terms to Your New ProgramsIf you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.one line to give the program's name and an idea of what it does.Copyright (C) yyyy name of author6 行未改动This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.Also add information on how to contact you by electronic and paper mail.If the program is interactive, make it output a short notice like this when it starts in an interactive mode:Gnomovision version 69, Copyright (C) year name of authorGnomovision comes with ABSOLUTELY NO WARRANTY; for detailstype `show w'. This is free software, and you are welcometo redistribute it under certain conditions; type `show c'for details.The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:Yoyodyne, Inc., hereby disclaims all copyrightinterest in the program `Gnomovision'(which makes passes at compilers) writtenby James Hacker.signature of Ty Coon, 1 April 1989Ty Coon, President of ViceThis General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License.)";case Gnuver::V3:return R"(GNU GENERAL PUBLIC LICENSEVersion 3, 29 June 2007Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>Everyone is permitted to copy and distribute verbatim copiesof this license document, but changing it is not allowed.PreambleThe GNU General Public License is a free, copyleft license forsoftware and other kinds of works.The licenses for most software and other practical works are designedto take away your freedom to share and change the works. By contrast,the GNU General Public License is intended to guarantee your freedom toshare and change all versions of a program--to make sure it remains freesoftware for all its users. We, the Free Software Foundation, use theGNU General Public License for most of our software; it applies also toany other work released this way by its authors. You can apply it toyour programs, too.When we speak of free software, we are referring to freedom, notprice. Our General Public Licenses are designed to make sure that youhave the freedom to distribute copies of free software (and charge forthem if you wish), that you receive source code or can get it if youwant it, that you can change the software or use pieces of it in newfree programs, and that you know you can do these things.To protect your rights, we need to prevent others from denying youthese rights or asking you to surrender the rights. Therefore, you havecertain responsibilities if you distribute copies of the software, or ifyou modify it: responsibilities to respect the freedom of others.For example, if you distribute copies of such a program, whethergratis or for a fee, you must pass on to the recipients the samefreedoms that you received. You must make sure that they, too, receiveor can get the source code. And you must show them these terms so theyknow their rights.Developers that use the GNU GPL protect your rights with two steps:(1) assert copyright on the software, and (2) offer you this Licensegiving you legal permission to copy, distribute and/or modify it.For the developers' and authors' protection, the GPL clearly explainsthat there is no warranty for this free software. For both users' andauthors' sake, the GPL requires that modified versions be marked aschanged, so that their problems will not be attributed erroneously toauthors of previous versions.Some devices are designed to deny users access to install or runmodified versions of the software inside them, although the manufacturercan do so. This is fundamentally incompatible with the aim ofprotecting users' freedom to change the software. The systematic2 行未改动have designed this version of the GPL to prohibit the practice for thoseproducts. If such problems arise substantially in other domains, westand ready to extend this provision to those domains in future versionsof the GPL, as needed to protect the freedom of users.Finally, every program is threatened constantly by software patents.States should not allow patents to restrict development and use ofsoftware on general-purpose computers, but in those that do, we wish toavoid the special danger that patents applied to a free program couldmake it effectively proprietary. To prevent this, the GPL assures thatpatents cannot be used to render the program non-free.The precise terms and conditions for copying, distribution andmodification follow.TERMS AND CONDITIONS0. Definitions."This License" refers to version 3 of the GNU General Public License."Copyright" also means copyright-like laws that apply to other kinds ofworks, such as semiconductor masks."The Program" refers to any copyrightable work licensed under thisLicense. Each licensee is addressed as "you". "Licensees" and"recipients" may be individuals or organizations.To "modify" a work means to copy from or adapt all or part of the workin a fashion requiring copyright permission, other than the making of anexact copy. The resulting work is called a "modified version" of theearlier work or a work "based on" the earlier work.A "covered work" means either the unmodified Program or a work basedon the Program.To "propagate" a work means to do anything with it that, withoutpermission, would make you directly or secondarily liable forinfringement under applicable copyright law, except executing it on acomputer or modifying a private copy. Propagation includes copying,distribution (with or without modification), making available to thepublic, and in some countries other activities as well.To "convey" a work means any kind of propagation that enables otherparties to make or receive copies. Mere interaction with a user througha computer network, with no transfer of a copy, is not conveying.An interactive user interface displays "Appropriate Legal Notices"to the extent that it includes a convenient and prominently visiblefeature that (1) displays an appropriate copyright notice, and (2)tells the user that there is no warranty for the work (except to theextent that warranties are provided), that licensees may convey thework under this License, and how to view a copy of this License. Ifthe interface presents a list of user commands or options, such as amenu, a prominent item in the list meets this criterion.1. Source Code.The "source code" for a work means the preferred form of the workfor making modifications to it. "Object code" means any non-sourceform of a work.A "Standard Interface" means an interface that either is an officialstandard defined by a recognized standards body, or, in the case ofinterfaces specified for a particular programming language, one thatis widely used among developers working in that language.The "System Libraries" of an executable work include anything, otherthan the work as a whole, that (a) is included in the normal form ofpackaging a Major Component, but which is not part of that MajorComponent, and (b) serves only to enable use of the work with that2 行未改动"Major Component", in this context, means a major essential component(kernel, window system, and so on) of the specific operating system(if any) on which the executable work runs, or a compiler used toproduce the work, or an object code interpreter used to run it.The "Corresponding Source" for a work in object code form means allthe source code needed to generate, install, and (for an executablework) run the object code and to modify the work, including scripts tocontrol those activities. However, it does not include the work's4 行未改动the work, and the source code for shared libraries and dynamicallylinked subprograms that the work is specifically designed to require,such as by intimate data communication or control flow between thosesubprograms and other parts of the work.The Corresponding Source need not include anything that userscan regenerate automatically from other parts of the CorrespondingSource.The Corresponding Source for a work in source code form is thatsame work.2. Basic Permissions.All rights granted under this License are granted for the term ofcopyright on the Program, and are irrevocable provided the statedconditions are met. This License explicitly affirms your unlimitedpermission to run the unmodified Program. The output from running acovered work is covered by this License only if the output, given itscontent, constitutes a covered work. This License acknowledges yourrights of fair use or other equivalent, as provided by copyright law.You may make, run and propagate covered works that you do notconvey, without conditions so long as your license otherwise remainsin force. You may convey covered works to others for the sole purposeof having them make modifications exclusively for you, or provide you2 行未改动not control copyright. Those thus making or running the covered worksfor you must do so exclusively on your behalf, under your directionand control, on terms that prohibit them from making any copies ofyour copyrighted material outside their relationship with you.Conveying under any other circumstances is permitted solely underthe conditions stated below. Sublicensing is not allowed; section 10makes it unnecessary.3. Protecting Users' Legal Rights From Anti-Circumvention Law.No covered work shall be deemed part of an effective technologicalmeasure under any applicable law fulfilling obligations under article11 of the WIPO copyright treaty adopted on 20 December 1996, orsimilar laws prohibiting or restricting circumvention of suchmeasures.When you convey a covered work, you waive any legal power to forbidcircumvention of technological measures to the extent such circumventionis effected by exercising rights under this License with respect tothe covered work, and you disclaim any intention to limit operation ormodification of the work as a means of enforcing, against the work'susers, your or third parties' legal rights to forbid circumvention oftechnological measures.4. Conveying Verbatim Copies.You may convey verbatim copies of the Program's source code as youreceive it, in any medium, provided that you conspicuously andappropriately publish on each copy an appropriate copyright notice;keep intact all notices stating that this License and anynon-permissive terms added in accord with section 7 apply to the code;keep intact all notices of the absence of any warranty; and give allrecipients a copy of this License along with the Program.You may charge any price or no price for each copy that you convey,and you may offer support or warranty protection for a fee.5. Conveying Modified Source Versions.You may convey a work based on the Program, or the modifications toproduce it from the Program, in the form of source code under theterms of section 4, provided that you also meet all of these conditions:a) The work must carry prominent notices stating that you modifiedit, and giving a relevant date.b) The work must carry prominent notices stating that it is7 行未改动additional terms, to the whole of the work, and all its parts,regardless of how they are packaged. This License gives nopermission to license the work in any other way, but it does notinvalidate such permission if you have separately received it.d) If the work has interactive user interfaces, each must displayAppropriate Legal Notices; however, if the Program has interactiveinterfaces that do not display Appropriate Legal Notices, yourwork need not make them do so.A compilation of a covered work with other separate and independentworks, which are not by their nature extensions of the covered work,and which are not combined with it such as to form a larger program,in or on a volume of a storage or distribution medium, is called an"aggregate" if the compilation and its resulting copyright are notused to limit the access or legal rights of the compilation's usersbeyond what the individual works permit. Inclusion of a covered workin an aggregate does not cause this License to apply to the otherparts of the aggregate.6. Conveying Non-Source Forms.You may convey a covered work in object code form under the termsof sections 4 and 5, provided that you also convey themachine-readable Corresponding Source under the terms of this License,in one of these ways:a) Convey the object code in, or embodied in, a physical product(including a physical distribution medium), accompanied by theCorresponding Source fixed on a durable physical mediumcustomarily used for software interchange.b) Convey the object code in, or embodied in, a physical product(including a physical distribution medium), accompanied by awritten offer, valid for at least three years and valid for aslong as you offer spare parts or customer support for that product3 行未改动medium customarily used for software interchange, for a price nomore than your reasonable cost of physically performing thisconveying of source, or (2) access to copy theCorresponding Source from a network server at no charge.c) Convey individual copies of the object code with a copy of thewritten offer to provide the Corresponding Source. Thisalternative is allowed only occasionally and noncommercially, andonly if you received the object code with such an offer, in accordwith subsection 6b.d) Convey the object code by offering access from a designatedplace (gratis or for a charge), and offer equivalent access to theCorresponding Source in the same way through the same place at nofurther charge. You need not require recipients to copy the4 行未改动clear directions next to the object code saying where to find theCorresponding Source. Regardless of what server hosts theCorresponding Source, you remain obligated to ensure that it isavailable for as long as needed to satisfy these requirements.e) Convey the object code using peer-to-peer transmission, providedyou inform other peers where the object code and CorrespondingSource of the work are being offered to the general public at nocharge under subsection 6d.13 行未改动actually uses, or expects or is expected to use, the product. A productis a consumer product regardless of whether the product has substantialcommercial, industrial or non-consumer uses, unless such uses representthe only significant mode of use of the product."Installation Information" for a User Product means any methods,procedures, authorization keys, or other information required to installand execute modified versions of a covered work in that User Product froma modified version of its Corresponding Source. The information mustsuffice to ensure that the continued functioning of the modified objectcode is in no case prevented or interfered with solely becausemodification has been made.If you convey an object code work under this section in, or with, orspecifically for use in, a User Product, and the conveying occurs aspart of a transaction in which the right of possession and use of theUser Product is transferred to the recipient in perpetuity or for a2 行未改动by the Installation Information. But this requirement does not applyif neither you nor any third party retains the ability to installmodified object code on the User Product (for example, the work hasbeen installed in ROM).The requirement to provide Installation Information does not include arequirement to continue to provide support service, warranty, or updatesfor a work that has been modified or installed by the recipient, or forthe User Product in which it has been modified or installed. Access to anetwork may be denied when the modification itself materially andadversely affects the operation of the network or violates the rules andprotocols for communication across the network.Corresponding Source conveyed, and Installation Information provided,in accord with this section must be in a format that is publiclydocumented (and with an implementation available to the public insource code form), and must require no special password or key forunpacking, reading or copying.7. Additional Terms."Additional permissions" are terms that supplement the terms of thisLicense by making exceptions from one or more of its conditions.Additional permissions that are applicable to the entire Program shallbe treated as though they were included in this License, to the extentthat they are valid under applicable law. If additional permissionsapply only to part of the Program, that part may be used separatelyunder those permissions, but the entire Program remains governed bythis License without regard to the additional permissions.When you convey a copy of a covered work, you may at your optionremove any additional permissions from that copy, or from any part ofit. (Additional permissions may be written to require their ownremoval in certain cases when you modify the work.) You may placeadditional permissions on material, added by you to a covered work,for which you have or can give appropriate copyright permission.Notwithstanding any other provision of this License, for material youadd to a covered work, you may (if authorized by the copyright holders ofthat material) supplement the terms of this License with terms:a) Disclaiming warranty or limiting liability differently from theterms of sections 15 and 16 of this License; orb) Requiring preservation of specified reasonable legal notices or14 行未改动material by anyone who conveys the material (or modified versions ofit) with contractual assumptions of liability to the recipient, forany liability that these contractual assumptions directly impose onthose licensors and authors.All other non-permissive additional terms are considered "furtherrestrictions" within the meaning of section 10. If the Program as youreceived it, or any part of it, contains a notice stating that it isgoverned by this License along with a term that is a furtherrestriction, you may remove that term. If a license document containsa further restriction but permits relicensing or conveying under thisLicense, you may add to a covered work material governed by the termsof that license document, provided that the further restriction doesnot survive such relicensing or conveying.If you add terms to a covered work in accord with this section, youmust place, in the relevant source files, a statement of theadditional terms that apply to those files, or a notice indicatingwhere to find the applicable terms.Additional terms, permissive or non-permissive, may be stated in theform of a separately written license, or stated as exceptions;the above requirements apply either way.10 行未改动provisionally, unless and until the copyright holder explicitly andfinally terminates your license, and (b) permanently, if the copyrightholder fails to notify you of the violation by some reasonable meansprior to 60 days after the cessation.Moreover, your license from a particular copyright holder isreinstated permanently if the copyright holder notifies you of theviolation by some reasonable means, this is the first time you havereceived notice of violation of this License (for any work) from thatcopyright holder, and you cure the violation prior to 30 days afteryour receipt of the notice.Termination of your rights under this section does not terminate thelicenses of parties who have received copies or rights from you underthis License. If your rights have been terminated and not permanentlyreinstated, you do not qualify to receive new licenses for the samematerial under section 10.9. Acceptance Not Required for Having Copies.You are not required to accept this License in order to receive orrun a copy of the Program. Ancillary propagation of a covered workoccurring solely as a consequence of using peer-to-peer transmissionto receive a copy likewise does not require acceptance. However,nothing other than this License grants you permission to propagate ormodify any covered work. These actions infringe copyright if you donot accept this License. Therefore, by modifying or propagating acovered work, you indicate your acceptance of this License to do so.10. Automatic Licensing of Downstream Recipients.Each time you convey a covered work, the recipient automaticallyreceives a license from the original licensors, to run, modify andpropagate that work, subject to this License. You are not responsiblefor enforcing compliance by third parties with this License.An "entity transaction" is a transaction transferring control of anorganization, or substantially all assets of one, or subdividing anorganization, or merging organizations. If propagation of a coveredwork results from an entity transaction, each party to thattransaction who receives a copy of the work also receives whateverlicenses to the work the party's predecessor in interest had or couldgive under the previous paragraph, plus a right to possession of theCorresponding Source of the work from the predecessor in interest, ifthe predecessor has it or can get it with reasonable efforts.You may not impose any further restrictions on the exercise of therights granted or affirmed under this License. For example, you maynot impose a license fee, royalty, or other charge for exercise ofrights granted under this License, and you may not initiate litigation(including a cross-claim or counterclaim in a lawsuit) alleging thatany patent claim is infringed by making, using, selling, offering forsale, or importing the Program or any portion of it.11. Patents.A "contributor" is a copyright holder who authorizes use under thisLicense of the Program or a work on which the Program is based. Thework thus licensed is called the contributor's "contributor version".A contributor's "essential patent claims" are all patent claimsowned or controlled by the contributor, whether already acquired orhereafter acquired, that would be infringed by some manner, permittedby this License, of making, using, or selling its contributor version,but do not include claims that would be infringed only as aconsequence of further modification of the contributor version. Forpurposes of this definition, "control" includes the right to grantpatent sublicenses in a manner consistent with the requirements ofthis License.Each contributor grants you a non-exclusive, worldwide, royalty-freepatent license under the contributor's essential patent claims, tomake, use, sell, offer for sale, import and otherwise run, modify andpropagate the contents of its contributor version.In the following three paragraphs, a "patent license" is any expressagreement or commitment, however denominated, not to enforce a patent(such as an express permission to practice a patent or covenant not tosue for patent infringement). To "grant" such a patent license to aparty means to make such an agreement or commitment not to enforce apatent against the party.If you convey a covered work, knowingly relying on a patent license,and the Corresponding Source of the work is not available for anyoneto copy, free of charge and under the terms of this License, through apublicly available network server or other readily accessible means,5 行未改动actual knowledge that, but for the patent license, your conveying thecovered work in a country, or your recipient's use of the covered workin a country, would infringe one or more identifiable patents in thatcountry that you have reason to believe are valid.If, pursuant to or in connection with a single transaction orarrangement, you convey, or propagate by procuring conveyance of, acovered work, and grant a patent license to some of the partiesreceiving the covered work authorizing them to use, propagate, modifyor convey a specific copy of the covered work, then the patent licenseyou grant is automatically extended to all recipients of the coveredwork and works based on it.A patent license is "discriminatory" if it does not include withinthe scope of its coverage, prohibits the exercise of, or isconditioned on the non-exercise of one or more of the rights that arespecifically granted under this License. You may not convey a covered6 行未改动conveyed by you (or copies made from those copies), or (b) primarilyfor and in connection with specific products or compilations thatcontain the covered work, unless you entered into that arrangement,or that patent license was granted, prior to 28 March 2007.Nothing in this License shall be construed as excluding or limitingany implied license or other defenses to infringement that mayotherwise be available to you under applicable patent law.12. No Surrender of Others' Freedom.If conditions are imposed on you (whether by court order, agreement orotherwise) that contradict the conditions of this License, they do notexcuse you from the conditions of this License. If you cannot convey acovered work so as to satisfy simultaneously your obligations under thisLicense and any other pertinent obligations, then as a consequence you maynot convey it at all. For example, if you agree to terms that obligate youto collect a royalty for further conveying from those to whom you conveythe Program, the only way you could satisfy both those terms and thisLicense would be to refrain entirely from conveying the Program.13. Use with the GNU Affero General Public License.Notwithstanding any other provision of this License, you havepermission to link or combine any covered work with a work licensedunder version 3 of the GNU Affero General Public License into a singlecombined work, and to convey the resulting work. The terms of thisLicense will continue to apply to the part which is the covered work,but the special requirements of the GNU Affero General Public License,section 13, concerning interaction through a network will apply to thecombination as such.14. Revised Versions of this License.The Free Software Foundation may publish revised and/or new versions ofthe GNU General Public License from time to time. Such new versions willbe similar in spirit to the present version, but may differ in detail toaddress new problems or concerns.Each version is given a distinguishing version number. If theProgram specifies that a certain numbered version of the GNU GeneralPublic License "or any later version" applies to it, you have theoption of following the terms and conditions either of that numberedversion or of any later version published by the Free SoftwareFoundation. If the Program does not specify a version number of theGNU General Public License, you may choose any version ever publishedby the Free Software Foundation.If the Program specifies that a proxy can decide which futureversions of the GNU General Public License can be used, that proxy'spublic statement of acceptance of a version permanently authorizes youto choose that version for the Program.Later license versions may give you additional or differentpermissions. However, no additional obligations are imposed on anyauthor or copyright holder as a result of your choosing to follow alater version.15. Disclaimer of Warranty.THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BYAPPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHTHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTYOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULARPURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAMIS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OFALL NECESSARY SERVICING, REPAIR OR CORRECTION.16. Limitation of Liability.IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITINGWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYSTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANYGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THEUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OFDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRDPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OFSUCH DAMAGES.17. Interpretation of Sections 15 and 16.If the disclaimer of warranty and limitation of liability providedabove cannot be given local legal effect according to their terms,reviewing courts shall apply local law that most closely approximatesan absolute waiver of all civil liability in connection with theProgram, unless a warranty or assumption of liability accompanies acopy of the Program in return for a fee.END OF TERMS AND CONDITIONSHow to Apply These Terms to Your New ProgramsIf you develop a new program, and you want it to be of the greatestpossible use to the public, the best way to achieve this is to make itfree software which everyone can redistribute and change under these terms.To do so, attach the following notices to the program. It is safestto attach them to the start of each source file to most effectivelystate the exclusion of warranty; and each file should have at leastthe "copyright" line and a pointer to where the full notice is found.9 行未改动This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program. If not, see <https://www.gnu.org/licenses/>.Also add information on how to contact you by electronic and paper mail.If the program does terminal interaction, make it output a shortnotice like this when it starts in an interactive mode:<program> Copyright (C) <year> <name of author>This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.This is free software, and you are welcome to redistribute itunder certain conditions; type `show c' for details.The hypothetical commands `show w' and `show c' should show the appropriateparts of the General Public License. Of course, your program's commandsmight be different; for a GUI interface, you would use an "about box".You should also get your employer (if you work as a programmer) or school,if any, to sign a "copyright disclaimer" for the program, if necessary.For more information on this, and how to apply and follow the GNU GPL, see<https://www.gnu.org/licenses/>.The GNU General Public License does not permit incorporating your programinto proprietary programs. If your program is a subroutine library, youmay consider it more useful to permit linking proprietary applications withthe library. If this is what you want to do, use the GNU Lesser General2 行未改动)";case Gnuver::LGPL_V3:return R"(GNU LESSER GENERAL PUBLIC LICENSEVersion 3, 29 June 2007Copyright ? 2007 Free Software Foundation, Inc. <https://fsf.org/>Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.0. Additional Definitions.As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.1. Exception to Section 3 of the GNU GPL.You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.2. Conveying Modified Versions.If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, orb) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.3. Object Code Incorporating Material from Library Header Files.The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.b) Accompany the object code with a copy of the GNU GPL and this license document.4. Combined Works.You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.b) Accompany the Combined Work with a copy of the GNU GPL and this license document.c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.d) Do one of the following:0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)5. Combined Libraries.You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.6. Revised Versions of the GNU Lesser General Public License.The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.29 行未改动if (a == b) return "0";// 如果 a < b,交换并标记负号bool isNegative = false;if (!isGreaterOrEqual(a, b)){swap(a, b);isNegative = true;}string result;int i = a.size() - 1, j = b.size() - 1;int borrow = 0;while (i >= 0){int digitA = (a[i] - '0') - borrow;int digitB = (j >= 0) ? (b[j--] - '0') : 0;if (digitA < digitB){digitA += 10;borrow = 1;}else{borrow = 0;}17 行未改动return a >= b;}// 移除前导零void removeLeadingZeros(){size_t start = num.find_first_not_of('0');if (start == string::npos){num = "0";sign = true; // 0的符号为正}else{num = num.substr(start);}14 行未改动{sum += (a[i] - '0');i--;}if (j >= 0){sum += (b[j] - '0');j--;}80 行未改动Bigint() : num("0"), sign(true) {}Bigint(string s){if (s.empty()){num = "0";sign = true;return;3 行未改动if (s[0] == '-'){sign = false;s = s.substr(1);}else{sign = true;}5 行未改动return;}// 移除前导零size_t start = s.find_first_not_of('0');if (start == string::npos){num = "0";sign = true; // 0总是正数}else{num = s.substr(start);// 如果数字是"0",确保符号为正if (num == "0") sign = true;15 行未改动string a = this->num;string b = other.num;bool aSign = this->sign;bool bSign = other.sign;if (aSign == bSign){string result = add(a, b);return Bigint(aSign ? result : "-" + result);}else{if (aSign) // a正,b负 => a - |b|{string result = subtractNonNegative(a, b);if (result[0] == '-'){return Bigint("-" + result.substr(1));}else{return Bigint(result);}}else // a负,b正 => b - |a|{string result = subtractNonNegative(b, a);if (result[0] == '-'){return Bigint("-" + result.substr(1));}else{return Bigint(result);}}18 行未改动// 除法运算符Bigint operator/(const Bigint& other) const{if (other.num == "0"){throw runtime_error("Division by zero");}7 行未改动// 取模运算符Bigint operator%(const Bigint& other) const{if (other.num == "0"){throw runtime_error("Modulo by zero");}// 计算 a % b = a - (a / b) * bBigint quotient = *this / other;Bigint product = quotient * other;Bigint remainder = *this - product;return remainder;}Bigint& operator+=(const Bigint& other){19 行未改动{*this = *this % other;return *this;}bool operator==(const Bigint& other) const{return (sign == other.sign) && (num == other.num);}bool operator!=(const Bigint& other) const{return !(*this == other);}bool operator<(const Bigint& other) const{if (sign != other.sign){return sign < other.sign; // 负数 < 正数}if (sign) // 都是正数{if (num.length() != other.num.length())return num.length() < other.num.length();return num < other.num;}else // 都是负数{if (num.length() != other.num.length())return num.length() > other.num.length();return num > other.num;}}bool operator>(const Bigint& other) const{return other < *this;}bool operator<=(const Bigint& other) const{return !(*this > other);}bool operator>=(const Bigint& other) const{return !(*this < other);}friend ostream& operator<<(ostream& os, const Bigint& bigint){if (!bigint.sign && bigint.num != "0"){os << '-';22 行未改动};#endif#ifdef JTBG_KMPstruct kmp{private:string pattern;vector<int> next;2 行未改动int m = pattern.length();next.resize(m, 0);next[0] = -1;int i = 0, j = -1;while (i < m - 1){if (j == -1 || pattern[i] == pattern[j]){i++;j++;next[i] = j;}else{j = next[j];}}}public:kmp(const string& pat) : pattern(pat){buildNext();}// 搜索所有匹配位置vector<int> search(const string& text){vector<int> result;int n = text.length();int m = pattern.length();if (m == 0) return result;int i = 0, j = 0;while (i < n) {if (j == -1 || text[i] == pattern[j]){i++;j++;}else{j = next[j];}if (j == m){result.push_back(i - j);j = next[j - 1]; // 继续搜索i--; // 回退一步}}return result;}// 搜索第一个匹配位置,返回-1表示未找到int findFirst(const string& text){int n = text.length();int m = pattern.length();if (m == 0) return 0;int i = 0, j = 0;while (i < n && j < m){if (j == -1 || text[i] == pattern[j]){i++;j++;}else{j = next[j];}}return (j == m) ? (i - j) : -1;}// 判断是否包含模式串bool contains(const string& text){return findFirst(text) != -1;}// 获取next数组(用于调试)vector<int> getNext() const{return next;}// 统计匹配次数int count(const string& text){return search(text).size();}};5 行未改动void pre(int argc,char** argv){cout << "程序名: " << argv[0] << endl;cout << "参数数量: " << argc - 1 << endl;for (int i = 1; i < argc; i++){cout << "参数 " << i << ": " << argv[i] << endl;}}vector<string> ToVector(int argc, char** argv){vector<string> args;for (int i = 1; i < argc; i++){args.push_back(string(argv[i]));}return args;}map<string, string> ToKeyValue(int argc, char** argv){map<string, string> params;for (int i = 1; i < argc; i++){string arg = argv[i];// 检查是否是 --key=value 格式if (arg.substr(0, 2) == "--"){size_t pos = arg.find('=');if (pos != string::npos){string key = arg.substr(2, pos - 2);string value = arg.substr(pos + 1);params[key] = value;}else{// 只有键没有值params[arg.substr(2)] = "true";}}// 检查是否是 -key value 格式else if (arg.substr(0, 1) == "-"){string key = arg.substr(1);if (i + 1 < argc && argv[i + 1][0] != '-'){params[key] = argv[i + 1];i++; // 跳过下一个参数}else{params[key] = "true";}}}return params;}};#endif84 行未改动0,KEY_SET_VALUE,&hKey);if (ret != ERROR_SUCCESS){return false;}// 设置DWORD类型键值ret = RegSetValueExW(hKey,valueName,0,REG_DWORD,(const BYTE*)&value,sizeof(DWORD));if (ret != ERROR_SUCCESS){RegCloseKey(hKey);return false;}RegCloseKey(hKey); // 关闭注册表句柄return true;}bool SetShowFileExtensions(bool showExt=1)8 行未改动0, // 保留参数KEY_SET_VALUE, // 访问权限&hKey // 输出打开的键句柄);if (ret != ERROR_SUCCESS){return false;}// 2. 设置键值:0表示显示,1表示隐藏5 行未改动REG_DWORD, // 数据类型(32位整数)(const BYTE*)&value,// 数据缓冲区sizeof(DWORD) // 数据长度);if (ret != ERROR_SUCCESS){RegCloseKey(hKey); // 关闭注册表句柄return false;}3 行未改动SHCNF_IDLIST, // 数据类型:ID列表(无具体数据时用此)nullptr, // 无具体数据nullptr // 无具体数据);return true;}bool SetShowHiddenFiles(bool show){const wchar_t* regPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced";DWORD value = show ? 1 : 2; // 注意:Hidden键的取值是1=显示,2=隐藏(特殊规则)if (!SetRegistryDwordValue(regPath, L"Hidden", value)){return false;}return true;}bool SetShowSystemFiles(bool show){const wchar_t* regPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced";DWORD value = show ? 1 : 0; // 1=显示系统文件,0=隐藏if (!SetRegistryDwordValue(regPath, L"ShowSuperHidden", value)){return false;}return true;}bool SetHideEmptyDrives(bool hide){const wchar_t* regPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced";DWORD value = hide ? 1 : 0; // 1=隐藏无介质驱动器,0=显示if (!SetRegistryDwordValue(regPath, L"HideDrivesWithNoMedia", value)){return false;}return true;}bool ReadRegistryString(HKEY rootKey, const wchar_t* subKey, const wchar_t* valueName, wstring& outStr){HKEY hKey = nullptr;LONG ret = RegOpenKeyExW(rootKey, subKey, 0, KEY_READ, &hKey);if (ret != ERROR_SUCCESS){return false;}// 第一步:调用RegQueryValueExW获取字符串的长度(dataSize返回所需缓冲区大小)DWORD dataType = 0;DWORD dataSize = 0;ret = RegQueryValueExW(3 行未改动&dataType,nullptr, // 缓冲区为null,仅获取长度&dataSize);if (ret != ERROR_SUCCESS && ret != ERROR_MORE_DATA){RegCloseKey(hKey);return false;}// 第二步:分配缓冲区,读取字符串bool success = false;if (dataType == REG_SZ || dataType == REG_EXPAND_SZ){wchar_t* buffer = new wchar_t[dataSize / sizeof(wchar_t)]; // 按宽字符分配ret = RegQueryValueExW(hKey,2 行未改动&dataType,(LPBYTE)buffer,&dataSize);if (ret == ERROR_SUCCESS){outStr = buffer; // 赋值到wstringsuccess = true;}delete[] buffer; // 释放缓冲区}RegCloseKey(hKey);return success;}bool ReadRegistryDword(HKEY rootKey, const wchar_t* subKey, const wchar_t* valueName, DWORD& outValue){HKEY hKey = nullptr;LONG ret = RegOpenKeyExW(rootKey,subKey,0,KEY_READ,&hKey);if (ret != ERROR_SUCCESS){return false;}// 2. 查询键值:先获取数据长度(此处DWORD固定为4字节,也可动态获取)DWORD dataType = 0;DWORD dataSize = sizeof(DWORD);ret = RegQueryValueExW(3 行未改动&dataType, // 输出实际值类型(LPBYTE)&outValue, // 存储读取的数据&dataSize // 输入缓冲区大小,输出实际数据大小);// 3. 校验结果:类型匹配 + 操作成功bool success = false;if (ret == ERROR_SUCCESS){if (dataType == REG_DWORD){success = true;}}RegCloseKey(hKey);return success;}47 行未改动#define RESUME 0#define SUSPEND 1#ifndef NO_DEBUGPROSDWORD GetProcessIdByName(const char* processName){DWORD processId = 0;HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);if (hSnapshot != INVALID_HANDLE_VALUE){PROCESSENTRY32 processEntry;processEntry.dwSize = sizeof(PROCESSENTRY32);if (Process32First(hSnapshot, &processEntry)){do{if (strcmp(processEntry.szExeFile, processName) == 0){processId = processEntry.th32ProcessID;6 行未改动return processId;}// 使用DebugActiveProcess挂起进程bool SuspendProcessByDebug(DWORD processId){if (DebugActiveProcess(processId)){return true;3 行未改动// 恢复被Debug挂起的进程bool ResumeProcessByDebug(DWORD processId){if (DebugActiveProcessStop(processId)){return true;}return false;10 行未改动#ifndef NO_NTPPORStypedef LONG (NTAPI *NtSuspendProcess)(IN HANDLE ProcessHandle);typedef LONG (NTAPI *NtResumeProcess)(IN HANDLE ProcessHandle);// 使用NtSuspendProcess挂起进程bool SuspendProcessByNt(DWORD processId){HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);if (hProcess == NULL){return false;}// 获取NtSuspendProcess函数HMODULE hNtDll = GetModuleHandle("ntdll.dll");if (hNtDll == NULL){CloseHandle(hProcess);return false;}NtSuspendProcess pNtSuspendProcess =(NtSuspendProcess)GetProcAddress(hNtDll, "NtSuspendProcess");if (pNtSuspendProcess != NULL){LONG status = pNtSuspendProcess(hProcess);CloseHandle(hProcess);if (status == 0){ // STATUS_SUCCESScout << "进程 " << processId << " 已被挂起 (Nt方法)" << endl;return true;}}CloseHandle(hProcess);return false;}// 恢复进程bool ResumeProcessByNt(DWORD processId){HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processId);if (hProcess == NULL){return false;}HMODULE hNtDll = GetModuleHandle("ntdll.dll");if (hNtDll == NULL){CloseHandle(hProcess);return false;}NtResumeProcess pNtResumeProcess =(NtResumeProcess)GetProcAddress(hNtDll, "NtResumeProcess");if (pNtResumeProcess != NULL){LONG status = pNtResumeProcess(hProcess);CloseHandle(hProcess);if (status == 0){cout << "进程 " << processId << " 已恢复 (Nt方法)" << endl;return true;}}CloseHandle(hProcess);return false;}8 行未改动#ifndef NO_TerminateProcessbool KillProcByTer(DWORD processId, UINT exitCode = 0){HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, processId);if (hProcess == NULL){return false;}if (TerminateProcess(hProcess, exitCode)){CloseHandle(hProcess);return true;}else{CloseHandle(hProcess);return false;}}#endif#ifndef NO_NTTERMINATEtypedef LONG (NTAPI *NtTerminateProcess)(HANDLE ProcessHandle, LONG ExitStatus);bool KillProcByNt(DWORD processId, LONG exitCode = 0){HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, processId);if (hProcess == NULL){return false;}HMODULE hNtDll = GetModuleHandle("ntdll.dll");if (hNtDll == NULL){CloseHandle(hProcess);return false;}NtTerminateProcess pNtTerminateProcess =(NtTerminateProcess)GetProcAddress(hNtDll, "NtTerminateProcess");if (pNtTerminateProcess != NULL){LONG status = pNtTerminateProcess(hProcess, exitCode);CloseHandle(hProcess);if (status == 0){ // STATUS_SUCCESSreturn true;}}CloseHandle(hProcess);return false;}#endifBOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam){DWORD targetProcessId = (DWORD)lParam;DWORD windowProcessId;GetWindowThreadProcessId(hwnd, &windowProcessId);if (windowProcessId == targetProcessId){// 发送关闭消息PostMessage(hwnd, WM_CLOSE, 0, 0);5 行未改动// 向进程的所有窗口发送关闭消息EnumWindows(EnumWindowsProc, (LPARAM)processId);// 等待进程退出HANDLE hProcess = OpenProcess(SYNCHRONIZE, FALSE, processId);if (hProcess == NULL){return KillProcByTer(processId);}DWORD waitResult = WaitForSingleObject(hProcess, waitTimeout);CloseHandle(hProcess);if (waitResult == WAIT_OBJECT_0){return true;}else{return KillProcByTer(processId);}}#endif#ifdef JTBG_UDPclass UDPSocket{public:// 手动实现 inet_pton (字符串转网络地址)static inet_pton(int af, const char* src, void* dst){if (af != AF_INET){return -1; // 只支持 IPv4}uint32_t ip=0;int parts[4];int count = sscanf(src, "%d.%d.%d.%d", &parts[0], &parts[1], &parts[2], &parts[3]);if (count != 4){return 0; // 格式错误}for (int i = 0; i < 4; i++){if (parts[i] < 0 || parts[i] > 255){return 0; // 数值越界}ip = (ip << 8) | (parts[i] & 0xFF);}*((uint32_t*)dst) = htonl(ip);return 1;}// 手动实现 inet_ntop (网络地址转字符串)static const char* inet_ntop(int af, const void* src, char* dst, socklen_t size){if (af != AF_INET || size < INET_ADDRSTRLEN){return nullptr;}uint32_t ip = ntohl(*((const uint32_t*)src));snprintf(dst, size, "%d.%d.%d.%d",(ip >> 24) & 0xFF,(ip >> 16) & 0xFF,(ip >> 8) & 0xFF,ip & 0xFF);return dst;}using ReceiveCallback = function<void(const vector<uint8_t>& data,const sockaddr_in& from,int dataSize)>;using ErrorCallback = function<void(const string& error)>;// 构造函数和析构函数UDPSocket();~UDPSocket();// 禁止拷贝UDPSocket(const UDPSocket&) = delete;UDPSocket& operator=(const UDPSocket&) = delete;// 移动构造和赋值UDPSocket(UDPSocket&& other) noexcept;UDPSocket& operator=(UDPSocket&& other) noexcept;// 基本操作bool create();bool bind(uint16_t port, const string& address = "0.0.0.0");bool close();// 发送数据int sendTo(const vector<uint8_t>& data,const string& ip, uint16_t port);int sendTo(const uint8_t* data, size_t size,const string& ip, uint16_t port);// 接收数据(阻塞模式)int receiveFrom(vector<uint8_t>& buffer,string& fromIP, uint16_t& fromPort,int timeoutMs = -1);// 设置套接字选项bool setBroadcast(bool enable);bool setReuseAddress(bool enable);bool setNonBlocking(bool enable);bool setReceiveBufferSize(int size);bool setSendBufferSize(int size);bool setTTL(int ttl);// 异步操作bool startAsyncReceive(const ReceiveCallback& receiveCallback,const ErrorCallback& errorCallback = nullptr);void stopAsyncReceive();// 属性获取bool isValid() const { return socket_ != INVALID_SOCKET; }uint16_t getLocalPort() const { return localPort_; }string getLocalAddress() const { return localAddress_; }bool isAsyncReceiving() const { return asyncReceiving_; }private:SOCKET socket_;string localAddress_;uint16_t localPort_;// 异步接收相关atomic<bool> asyncReceiving_;thread receiveThread_;ReceiveCallback receiveCallback_;ErrorCallback errorCallback_;// 初始化Winsockstatic bool initializeWinsock();static void cleanupWinsock();static atomic<int> winsockRefCount_;// 线程函数void asyncReceiveThread();// 工具函数static string ipToString(const sockaddr_in& addr);static uint16_t portFromSockaddr(const sockaddr_in& addr);static bool stringToSockaddr(const string& ip, uint16_t port, sockaddr_in& addr);};// 实现部分inline UDPSocket::UDPSocket(): socket_(INVALID_SOCKET), localPort_(0), asyncReceiving_(false){initializeWinsock();}inline UDPSocket::~UDPSocket(){close();stopAsyncReceive();cleanupWinsock();2 行未改动inline UDPSocket::UDPSocket(UDPSocket&& other) noexcept: socket_(other.socket_), localAddress_(move(other.localAddress_)), localPort_(other.localPort_), asyncReceiving_(other.asyncReceiving_.load()){other.socket_ = INVALID_SOCKET;other.asyncReceiving_ = false;}inline UDPSocket& UDPSocket::operator=(UDPSocket&& other) noexcept{if (this != &other){close();stopAsyncReceive();socket_ = other.socket_;localAddress_ = move(other.localAddress_);localPort_ = other.localPort_;asyncReceiving_ = other.asyncReceiving_.load();other.socket_ = INVALID_SOCKET;other.asyncReceiving_ = false;}return *this;}inline bool UDPSocket::initializeWinsock(){if (winsockRefCount_++ == 0){WSADATA wsaData;WORD version = MAKEWORD(2, 2);if (WSAStartup(version, &wsaData) != 0){winsockRefCount_--;return false;}}return true;}inline void UDPSocket::cleanupWinsock(){if (--winsockRefCount_ == 0){WSACleanup();}}inline bool UDPSocket::create(){if (socket_ != INVALID_SOCKET){return true;}socket_ = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);if (socket_ == INVALID_SOCKET){return false;}return true;}inline bool UDPSocket::bind(uint16_t port, const string& address){if (!create()){return false;}sockaddr_in addr;if (!stringToSockaddr(address, port, addr)){return false;}if (::bind(socket_, reinterpret_cast<sockaddr*>(&addr), sizeof(addr)) == SOCKET_ERROR){return false;}// 获取绑定后的地址信息sockaddr_in localAddr;int addrLen = sizeof(localAddr);if (getsockname(socket_, reinterpret_cast<sockaddr*>(&localAddr), &addrLen) == 0){localAddress_ = ipToString(localAddr);localPort_ = portFromSockaddr(localAddr);}return true;}inline bool UDPSocket::close(){if (socket_ != INVALID_SOCKET){::closesocket(socket_);socket_ = INVALID_SOCKET;}return true;}inline int UDPSocket::sendTo(const vector<uint8_t>& data,const string& ip, uint16_t port){return sendTo(data.data(), data.size(), ip, port);}inline int UDPSocket::sendTo(const uint8_t* data, size_t size,const string& ip, uint16_t port){if (socket_ == INVALID_SOCKET || !data || size == 0){return -1;}sockaddr_in addr;if (!stringToSockaddr(ip, port, addr)){return -1;}int sent = ::sendto(socket_,reinterpret_cast<const char*>(data),static_cast<int>(size),0,reinterpret_cast<sockaddr*>(&addr),sizeof(addr));if (sent == SOCKET_ERROR){return -1;}return sent;}inline int UDPSocket::receiveFrom(vector<uint8_t>& buffer,string& fromIP, uint16_t& fromPort,int timeoutMs) {if (socket_ == INVALID_SOCKET){return -1;}// 设置超时if (timeoutMs >= 0){fd_set readSet;FD_ZERO(&readSet);FD_SET(socket_, &readSet);timeval timeout;timeout.tv_sec = timeoutMs / 1000;timeout.tv_usec = (timeoutMs % 1000) * 1000;int result = select(0, &readSet, nullptr, nullptr, &timeout);if (result == 0){return 0; // 超时}else if (result == SOCKET_ERROR){return -1;}}sockaddr_in fromAddr;int fromLen = sizeof(fromAddr);int received = ::recvfrom(socket_,reinterpret_cast<char*>(buffer.data()),static_cast<int>(buffer.size()),0,reinterpret_cast<sockaddr*>(&fromAddr),&fromLen);if (received == SOCKET_ERROR){return -1;}fromIP = ipToString(fromAddr);fromPort = portFromSockaddr(fromAddr);return received;}inline bool UDPSocket::setBroadcast(bool enable){if (socket_ == INVALID_SOCKET) return false;BOOL broadcast = enable ? TRUE : FALSE;return setsockopt(socket_, SOL_SOCKET, SO_BROADCAST,reinterpret_cast<char*>(&broadcast), sizeof(broadcast)) == 0;}inline bool UDPSocket::setReuseAddress(bool enable){if (socket_ == INVALID_SOCKET) return false;BOOL reuse = enable ? TRUE : FALSE;return setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR,reinterpret_cast<char*>(&reuse), sizeof(reuse)) == 0;}inline bool UDPSocket::setNonBlocking(bool enable){if (socket_ == INVALID_SOCKET) return false;u_long mode = enable ? 1 : 0;return ioctlsocket(socket_, FIONBIO, &mode) == 0;}inline bool UDPSocket::setReceiveBufferSize(int size){if (socket_ == INVALID_SOCKET) return false;return setsockopt(socket_, SOL_SOCKET, SO_RCVBUF,reinterpret_cast<char*>(&size), sizeof(size)) == 0;}inline bool UDPSocket::setSendBufferSize(int size){if (socket_ == INVALID_SOCKET) return false;return setsockopt(socket_, SOL_SOCKET, SO_SNDBUF,reinterpret_cast<char*>(&size), sizeof(size)) == 0;}inline bool UDPSocket::setTTL(int ttl){if (socket_ == INVALID_SOCKET) return false;return setsockopt(socket_, IPPROTO_IP, IP_TTL,reinterpret_cast<char*>(&ttl), sizeof(ttl)) == 0;}inline bool UDPSocket::startAsyncReceive(const ReceiveCallback& receiveCallback,const ErrorCallback& errorCallback){if (socket_ == INVALID_SOCKET || asyncReceiving_){return false;}receiveCallback_ = receiveCallback;errorCallback_ = errorCallback;asyncReceiving_ = true;receiveThread_ = thread(&UDPSocket::asyncReceiveThread, this);return true;}inline void UDPSocket::stopAsyncReceive(){if (asyncReceiving_){asyncReceiving_ = false;if (receiveThread_.joinable()){receiveThread_.join();}}}inline void UDPSocket::asyncReceiveThread(){vector<uint8_t> buffer(65507); // UDP最大数据包大小while (asyncReceiving_){string fromIP;uint16_t fromPort;int received = receiveFrom(buffer, fromIP, fromPort, 100); // 100ms超时if (received > 0 && receiveCallback_){sockaddr_in fromAddr;if (stringToSockaddr(fromIP, fromPort, fromAddr)){vector<uint8_t> data(buffer.begin(), buffer.begin() + received);receiveCallback_(data, fromAddr, received);}} else if (received == SOCKET_ERROR && errorCallback_){errorCallback_("接收数据出错");}}19 行未改动{memset(&addr, 0, sizeof(addr));addr.sin_family = AF_INET;addr.sin_port = htons(port);if (ip.empty() || ip == "0.0.0.0"){addr.sin_addr.s_addr = INADDR_ANY;}else if (ip == "255.255.255.255"){addr.sin_addr.s_addr = INADDR_BROADCAST;}else{if (inet_pton(AF_INET, ip.c_str(), &addr.sin_addr) != 1){return false;}}return true;}#endif6 行未改动#define PROGRESS_STYLE_DEFAULT "|"#define PROGRESS_STYLE_BLOCK "="#define PROGRESS_STYLE_DASH "-"class BarDrawer{ // 修正类名与使用处一致private:int total; // 总进度值int current; // 当前进度值int barLength; // 进度条长度string style; // 进度条样式bool showPercent; // 是否显示百分比bool showTime; // 是否显示时间chrono::steady_clock::time_point startTime; // 开始时间public:// 构造函数(修正:使用正确的构造函数语法)BarDrawer(int totalSteps, int length = 50,string barStyle = PROGRESS_STYLE_DEFAULT,bool percent = true, bool time = true): total(totalSteps), current(0), barLength(length),style(barStyle), showPercent(percent), showTime(time){startTime = chrono::steady_clock::now();}// 无参构造函数(解决实例化时的参数匹配问题)BarDrawer(): total(100), current(0), barLength(50),style(PROGRESS_STYLE_DEFAULT), showPercent(true), showTime(true){startTime = chrono::steady_clock::now();}// 更新进度void update(int steps = 1){current = min(current + steps, total);draw();}// 直接设置进度void setProgress(int value){current = max(0, min(value, total));draw();}// 完成进度void finish(){current = total;draw();cout << endl;}// 绘制进度条(修正:添加返回值或改为void)void draw(){double progress = static_cast<double>(current) / total;int filledLength = static_cast<int>(progress * barLength);// 计算已用时间auto now = chrono::steady_clock::now();auto elapsed = chrono::duration_cast<chrono::seconds>(now - startTime).count();// 绘制进度条(结合JTBG_COL模块的颜色功能)scg(LIGHT_GREEN, BLACK); // 设置绿色文本cout << "\r[";for (int i = 0; i < barLength; ++i){if (i < filledLength) cout << style;else cout << " ";}cout << "] ";// 显示百分比if (showPercent){scg(LIGHT_CYAN, BLACK); // 百分比用青色cout << fixed << setprecision(1)<< progress * 100 << "% ";}// 显示进度数值scg(WHITE, BLACK); // 数值用白色cout << current << "/" << total;// 显示时间if(showTime){scg(YELLOW, BLACK);cout << " (" << elapsed << "s)";}scg(WHITE, BLACK); // 恢复默认颜色cout.flush();}};12 行未改动{private:string num;bool negative;// 移除前导零void removeLeadingZeros(){size_t pos = num.find_first_not_of('0');if (pos == string::npos){num = "0";negative = false;}else{num = num.substr(pos);}if (num == "0") negative = false;}// 比较绝对值大小int compareAbsolute(const SimpleBigInt& other) const{if (num.length() != other.num.length()){return num.length() > other.num.length() ? 1 : -1;}return num.compare(other.num);}public:// 构造函数SimpleBigInt() : num("0"), negative(false) {}SimpleBigInt(long long n){if (n < 0){negative = true;n = -n;}else{negative = false;}num = to_string(n);}SimpleBigInt(const string& s){if (s.empty()){num = "0";negative = false;}else{if (s[0] == '-'){negative = true;num = s.substr(1);}else{negative = false;num = s;}}removeLeadingZeros();}// 转换为字符串string toString() const{return (negative ? "-" : "") + num;}// 获取数字字符串(无符号)string getNum() const{return num;}// 获取符号bool isNegative() const{return negative;}// 比较运算符bool operator==(const SimpleBigInt& other) const{return negative == other.negative && num == other.num;}bool operator!=(const SimpleBigInt& other) const{return !(*this == other);}bool operator<(const SimpleBigInt& other) const{if (negative != other.negative){4 行未改动return compareAbsolute(other) > 0;}return compareAbsolute(other) < 0;}bool operator<=(const SimpleBigInt& other) const{return *this < other || *this == other;}bool operator>(const SimpleBigInt& other) const{return !(*this <= other);}bool operator>=(const SimpleBigInt& other) const{return !(*this < other);}// 加法SimpleBigInt operator+(const SimpleBigInt& other) const{if (negative != other.negative){// 符号不同,转换为减法if (negative){SimpleBigInt temp = *this;temp.negative = false;return other - temp;}else{SimpleBigInt temp = other;temp.negative = false;return *this - temp;}}// 符号相同,直接相加string result;int carry = 0;int i = num.length() - 1;int j = other.num.length() - 1;while (i >= 0 || j >= 0 || carry > 0){int digit1 = i >= 0 ? num[i] - '0' : 0;int digit2 = j >= 0 ? other.num[j] - '0' : 0;int sum = digit1 + digit2 + carry;result.push_back((sum % 10) + '0');carry = sum / 10;i--;j--;}reverse(result.begin(), result.end());SimpleBigInt res(result);res.negative = negative;return res;}// 减法SimpleBigInt operator-(const SimpleBigInt& other) const{if (negative != other.negative){// 符号不同,转换为加法SimpleBigInt temp = other;temp.negative = !other.negative;return *this + temp;}// 符号相同,比较大小bool resultNegative = false;string a = num;string b = other.num;if (negative){// 都是负数:(-a) - (-b) = b - aswap(a, b);resultNegative = (compareAbsolute(other) > 0);}else{// 都是正数:a - bif (*this < other){swap(a, b);resultNegative = true;}}// 执行减法string result;int borrow = 0;int i = a.length() - 1;int j = b.length() - 1;while (i >= 0){int digit1 = a[i] - '0' - borrow;int digit2 = j >= 0 ? b[j] - '0' : 0;if (digit1 < digit2){digit1 += 10;borrow = 1;}else{borrow = 0;}result.push_back((digit1 - digit2) + '0');i--;j--;}// 移除结果中的前导零while (result.length() > 1 && result.back() == '0'){result.pop_back();}reverse(result.begin(), result.end());SimpleBigInt res(result);res.negative = resultNegative;return res;}// 乘法SimpleBigInt operator*(const SimpleBigInt& other) const{if (num == "0" || other.num == "0"){return SimpleBigInt("0");}int len1 = num.length();int len2 = other.num.length();vector<int> result(len1 + len2, 0);// 从低位到高位相乘for (int i = len1 - 1; i >= 0; i--){for (int j = len2 - 1; j >= 0; j--){int mul = (num[i] - '0') * (other.num[j] - '0');int sum = mul + result[i + j + 1];result[i + j + 1] = sum % 10;result[i + j] += sum / 10;}}// 转换为字符串string strResult;for (int digit : result){if (!(strResult.empty() && digit == 0)){strResult.push_back(digit + '0');}}if (strResult.empty()) strResult = "0";SimpleBigInt res(strResult);res.negative = (negative != other.negative);return res;}// 除法(返回商和余数)pair<SimpleBigInt, SimpleBigInt> divide(const SimpleBigInt& divisor) const{if (divisor == SimpleBigInt("0")){throw runtime_error("Division by zero");}SimpleBigInt dividend = *this;dividend.negative = false;SimpleBigInt div = divisor;div.negative = false;if (dividend < div){return {SimpleBigInt("0"), *this};}string quotient;string current;for (char digit : dividend.num){current.push_back(digit);SimpleBigInt cur(current);int count = 0;while (cur >= div){cur = cur - div;count++;}quotient.push_back(count + '0');current = cur.num;if (current == "0") {current.clear();}}// 移除商的前导零size_t pos = quotient.find_first_not_of('0');if (pos == string::npos){quotient = "0";}else{quotient = quotient.substr(pos);}SimpleBigInt q(quotient);SimpleBigInt r(current.empty() ? "0" : current);q.negative = (negative != divisor.negative);r.negative = negative; // 余数符号与被除数相同return {q, r};}// 除法运算符(返回商)SimpleBigInt operator/(const SimpleBigInt& other) const{return divide(other).first;}// 取模运算符SimpleBigInt operator%(const SimpleBigInt& other) const{return divide(other).second;}// 快速幂取模(核心算法)static SimpleBigInt modPow(SimpleBigInt base, SimpleBigInt exponent, SimpleBigInt modulus){if (modulus == SimpleBigInt("1")) return SimpleBigInt("0");if (exponent == SimpleBigInt("0")) return SimpleBigInt("1");SimpleBigInt result("1");base = base % modulus;// 将指数转换为二进制字符串string binary;SimpleBigInt exp = exponent;while (exp > SimpleBigInt("0")){// 检查最低位pair<SimpleBigInt, SimpleBigInt> divResult = exp.divide(SimpleBigInt("2"));if (divResult.second == SimpleBigInt("1")){binary = "1" + binary;}else{binary = "0" + binary;}exp = divResult.first; // exp = exp / 2}// 快速幂算法for (char bit : binary){result = (result * result) % modulus;if (bit == '1'){result = (result * base) % modulus;}}return result;}static pair<SimpleBigInt, SimpleBigInt> extendedGcd(SimpleBigInt a, SimpleBigInt b){if (b == SimpleBigInt("0")){return {SimpleBigInt("1"), SimpleBigInt("0")};}pair<SimpleBigInt, SimpleBigInt> temp = extendedGcd(b, a % b);SimpleBigInt x1 = temp.first;SimpleBigInt y1 = temp.second;SimpleBigInt x = y1;SimpleBigInt y = x1 - (a / b) * y1;return {x, y};}// 模逆元static SimpleBigInt modInverse(SimpleBigInt a, SimpleBigInt m){pair<SimpleBigInt, SimpleBigInt> gcdResult = extendedGcd(a, m);SimpleBigInt x = gcdResult.first;SimpleBigInt y = gcdResult.second;// 检查是否有逆元 (gcd(a, m) 必须为1)SimpleBigInt gcd = a * x + m * y;if (gcd != SimpleBigInt("1")){return SimpleBigInt("-1"); // 无逆元}// 确保结果为正SimpleBigInt result = x % m;if (result.isNegative()){result = result + m;}return result;}};// ============ RSA 实现 ============namespace RSA{using BigInt = SimpleBigInt;struct RSAKey{BigInt n; // 模数BigInt e; // 公钥指数BigInt d; // 私钥指数};// Miller-Rabin 素性测试(简化版)bool isPrimeSimple(const BigInt& n, int k = 5){if (n == BigInt("2") || n == BigInt("3")) return true;if (n < BigInt("2") || n % BigInt("2") == BigInt("0")) return false;// 将 n-1 分解为 d * 2^sBigInt d = n - BigInt("1");int s = 0;while (d % BigInt("2") == BigInt("0")){d = d / BigInt("2");s++;}srand(time(nullptr));for (int i = 0; i < k; i++){// 随机选择基数 aBigInt a(to_string(2 + rand() % 100)); // 简化:使用小随机数if (a >= n - BigInt("1")){a = BigInt("2");}BigInt x = BigInt::modPow(a, d, n);if (x == BigInt("1") || x == n - BigInt("1")) {continue;}bool composite = true;for (int j = 0; j < s - 1; j++){x = (x * x) % n;if (x == n - BigInt("1")){composite = false;break;}}if (composite){return false;}}return true;}// 生成素数(简化版)BigInt generatePrimeSimple(int bits = 16){if (bits < 8) bits = 8;srand(time(nullptr));int maxAttempts = 1000;for (int attempt = 0; attempt < maxAttempts; attempt++){// 生成随机数string numStr = "1"; // 确保最高位是1for (int i = 1; i < bits - 1; i++){numStr += (rand() % 2) ? '1' : '0';}numStr += '1'; // 确保是奇数BigInt candidate(numStr);// 快速检查小素数vector<int> smallPrimes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29};bool divisible = false;for (int prime : smallPrimes){if (candidate % BigInt(to_string(prime)) == BigInt("0")){divisible = true;break;}}if (divisible) continue;// 简化素性测试if (isPrimeSimple(candidate)){return candidate;}}// 如果没找到,返回一个已知的素数return BigInt("101");}// 生成RSA密钥对// 生成RSA密钥对(修复版)RSAKey generateKeyPair(int keySize = 64){RSAKey key;// 生成两个不同的素数BigInt p = generatePrimeSimple(keySize / 2);BigInt q = generatePrimeSimple(keySize / 2);while (q == p){q = generatePrimeSimple(keySize / 2);}// 计算 n = p * qkey.n = p * q;// 计算 φ(n) = (p-1)*(q-1)BigInt phi = (p - BigInt("1")) * (q - BigInt("1"));// 选择公钥指数 e(常用值)vector<int> eCandidates = {3, 5, 17, 257, 65537};bool found = false;for (int eVal : eCandidates){key.e = BigInt(to_string(eVal));// 修复:不使用结构化绑定pair<SimpleBigInt, SimpleBigInt> gcdResult = BigInt::extendedGcd(key.e, phi);SimpleBigInt gcd = gcdResult.first * key.e + gcdResult.second * phi;if (gcd == BigInt("1")){found = true;break;}}if (!found){// 尝试较小的奇数for (int eVal = 3; eVal < 100; eVal += 2){key.e = BigInt(to_string(eVal));// 修复:不使用结构化绑定pair<SimpleBigInt, SimpleBigInt> gcdResult = BigInt::extendedGcd(key.e, phi);SimpleBigInt gcd = gcdResult.first * key.e + gcdResult.second * phi;if (gcd == BigInt("1")){found = true;break;}}}if (!found){// 使用默认值key.e = BigInt("65537");}// 计算私钥指数 d = e^(-1) mod φ(n)key.d = BigInt::modInverse(key.e, phi);return key;}// 字符串编码为数字BigInt stringToNumber(const string& str){string encoded;for (char c : str){int ascii = static_cast<int>(c);stringstream ss;ss << setw(3) << setfill('0') << ascii;encoded += ss.str();}return BigInt(encoded);}// 数字解码为字符串string numberToString(const BigInt& num){string numStr = num.getNum();string decoded;// 补全到3的倍数while (numStr.length() % 3 != 0){numStr = "0" + numStr;}for (size_t i = 0; i < numStr.length(); i += 3){string triplet = numStr.substr(i, 3);int ascii = stoi(triplet);if (ascii >= 32 && ascii <= 126){ // 可打印字符decoded += static_cast<char>(ascii);}}return decoded;}// RSA加密BigInt rsaEncrypt(const BigInt& message, const BigInt& e, const BigInt& n){return BigInt::modPow(message, e, n);}// RSA解密BigInt rsaDecrypt(const BigInt& ciphertext, const BigInt& d, const BigInt& n){return BigInt::modPow(ciphertext, d, n);}// 字符串加密string encryptString(const string& plaintext, const BigInt& e, const BigInt& n){BigInt encoded = stringToNumber(plaintext);BigInt encrypted = rsaEncrypt(encoded, e, n);return encrypted.toString();}// 字符串解密string decryptString(const string& ciphertext, const BigInt& d, const BigInt& n){BigInt cipherNum(ciphertext);BigInt decrypted = rsaDecrypt(cipherNum, d, n);return numberToString(decrypted);}// 演示函数void demo(){cout << "\n=== 简单RSA演示 ===" << endl;cout << "注意:这是一个独立实现,不依赖外部库" << endl;// 生成密钥对cout << "\n1. 生成RSA密钥对..." << endl;RSAKey key = generateKeyPair(32);cout << "公钥 (n, e):" << endl;cout << " n = " << key.n.toString() << endl;cout << " e = " << key.e.toString() << endl;cout << "\n私钥 (n, d):" << endl;cout << " n = " << key.n.toString() << endl;cout << " d = " << key.d.toString() << endl;// 测试消息string testMessage = "HELLO";cout << "\n2. 测试加密/解密" << endl;cout << "原始消息: \"" << testMessage << "\"" << endl;// 加密string encrypted = encryptString(testMessage, key.e, key.n);cout << "加密后: " << encrypted << endl;// 解密string decrypted = decryptString(encrypted, key.d, key.n);cout << "解密后: \"" << decrypted << "\"" << endl;if (testMessage == decrypted){cout << "\n? RSA加解密成功!" << endl;}else{cout << "\n? RSA加解密失败!" << endl;}// 额外测试:验证数学运算cout << "\n3. 验证数学运算" << endl;cout << "测试: 5^3 mod 13" << endl;BigInt testResult = BigInt::modPow(BigInt("5"), BigInt("3"), BigInt("13"));729 行未改动全部展开