ACdream 1420 High Speed Trains(容斥原理+高精度)

High Speed Trains

Time Limit: 2000/1000MS (Java/Others)  Memory Limit: 128000/64000KB (Java/Others)
Problem Description

      The kingdom of Flatland has n cities. Recently the king of Flatland visited Japan and was amazed by high speed trains Shinkansens going all around the country. Therefore he decided to build the system of high speed trains in Flatland.

      Each high speed train line will be bidirectional and connect exactly two different cities of Flatland. Although there is actually no need of high speed trains in Flatland, the king ordered that there must be at least one high speed train line from each city of Flatland.
      The minister of transportation told the king that there are several train system satisfying his requirements. The king was amazed by the fact and asked the minister to count the number of possible systems.
      Help the minister to calculate the number of train systems.

Input
      The input file contains one integer number n (2 ≤ n ≤ 100)
Output
      Output one integer number — the number of different train systems that can be arranged in Flatland.
Sample Input
4
Sample Output
41

题目大意:

n个点,每个点至少连一条边,求方案数。

图可以不连通,如当n=4时,最少2条边。



解题思路:

昨天的专题简直就是java专场。


n最多100,可以先求出所以答案,再进行O(1)的查询。
首先i个点最多有(i-1)*i+1条边,每条边有存在与不存在2种状态,所以一共有tmp=2^((i-1)*i+1)-1种方案(减去的1指的是所有边全部不存在的情况)。

由于直接不好计算,所以我们可以考虑对立面。题目要求i个点全部有边相连,那么考虑至少有一个点没有一条边与它相连,即仅有2、3、4……i-1个点有边连接(没有1是因为一条边会连接2个点,不可能出现只有一个点有边的情况),这时发现这些数已经在计算ans[i]前计算出来了,所以只需要ans[i]=tmp-ans[2]*C[i][2]-ans[3]*C[i][3]-......ans[i-1]*C[i][i-1],出现组合数是因为每次要从i个点中挑出m个使这m个点有边连接,其余i-m个点无边连接,每次从i个点中挑出m个点的方案数是C[i][m]。

感谢某人的帮助


参考代码:

/*
* this code is made by Noooooorth
* Problem: 1420
* Verdict: Accepted
* Submission Date: 2015-08-25 22:13:25
* Time: 480MS
* Memory: 97148KB
*/
import java.util.*;
import java.math.*;

public class Main {	
	public static BigInteger C(int n,int m){
		BigInteger re=BigInteger.ONE;
		for(int i=1;i<=n;i++){
			re=re.multiply(BigInteger.valueOf(m-i+1)).divide(BigInteger.valueOf(i));
		}
		return re;
	}
	
	public static void main(String[] args) {
		BigInteger one=BigInteger.ONE;
		BigInteger two=BigInteger.valueOf(2);
		BigInteger ans[]=new BigInteger[105];
		ans[2]=one;
		for(int i=3;i<=100;i++){
			ans[i]=two.pow(i*(i-1)/2).subtract(one);
			for(int j=2;j<i;j++){
				ans[i]=ans[i].subtract(C(j,i).multiply(ans[j]));
			}
		}
		Scanner cin=new Scanner(System.in);
		while(cin.hasNext()){
			int n=cin.nextInt();
			System.out.println(ans[n]);
		}
	}
}

 还有一种炸天的方法(vj限制了代码长度,所有只能在ACdream上提交)

/*
* this code is made by Noooooorth
* Problem: 1420
* Verdict: Accepted
* Submission Date: 2015-08-25 22:11:33
* Time: 0MS
* Memory: 1732KB
*/
#include<bits/stdc++.h>
using namespace std;
string ans[105]=
{
    "-1",
    "-1",
    "1",
    "4",
    "41",
    "768",
    "27449",
    "1887284",
    "252522481",
    "66376424160",
    "34509011894545",
    "35645504882731588",
    "73356937912127722841",
    "301275024444053951967648",
    "2471655539737552842139838345",
    "40527712706903544101000417059892",
    "1328579255614092968399503598175745633",
    "87089694570964435671324844104521079746880",
    "11416413723839697400250507510852029840275473569",
    "2992938426499310900182770181410138818740061901947908",
    "1569215572908922308521995363961205592532386450494198274313",
    "1645471603165642700870123365352805341961877233365177453588005824",
    "3450836972657518843027307566308067339158750625752078009405689318211161",
    "14473931784997846210304793419064065231590568813586460830279677624521460536244",
    "121416458388792792649252647241600388956012443221106391448273002005554602042419577681",
    "2037032940918684178976184250818659345229517524662717388401435022357882783074342940728628000",
    "68351532186573198364243409327908758411752176373314636529587924648035548600802556000407708465724081",
    "4586995386488058986827880103080301055617470443300409663038804211130157172728628324791249533476741513190724",
    "615656218382767079140368523314666378067041110344327052442105313805257595292939851923944285549664502097869724318521",
    "165263974343529954317356861238565609447053351468551388266539403120010283263766600344094664895724527842711947319337103313248",
    "88725425253946577390137004665051099743341013053515477065967572044226981871352297413475235807042088670409886790198227401288743591849",
    "95268202520385526637986233936974667779805651033713707832000011893132709619843981574455460272576770474359430072502475845354724234793418238644",
    "204586909944926342215675757969328192615286275819478574751095918111085516479096593307895964518951913249145374978627151534646279971682839257270066349761",
    "878694093745349965033502594315633305831423348168716781855034808738594839478577490869993152277274474817150979968169377045130588455045403174167695472738397130880",
    "7547924819767483402367953301648843595390850857342001106183928279485100098009487488552358319055148904957428817509422944135401518398501749811772404830062788893611734127425",
    "129672361263353660738827839539965860638709352728998026184923084317268299008524142375422677379906565367543537959354092070023571030666511295683917950909129886198952449595855251572228",
    "4455508410978470007968344716866498138642471184517168554854220039545069131008871716588278712394969053537768722884017200452235232138712153670987234426768225423566577718431736193815342682614761",
    "306180206751230091016675467132732806798893016603488469464382061254229783345539134329714822285147261802483054650144190994569515229757634617032445053176772359567346044769376774208907346959234954879521408",
    "42081087200752140198248953190395581117582323875265366140515558020393583255681409821156659619010324997388625658087808979809018720113551029230344354336438422656082580309258109794130916057214438400291617976939494265",
    "11567161173227696466447336816695066165039763519419555325259691334406585295325501537840310316159938782586079387881820215182328454588950369084606665947871968713213238833370983458031060036209724293067527109814799128876919650612",
    "6359114105601017351408288878064905263866658953806880823736641946347481055240545062113184060591626390730626377931209552501152405879660090297634327028610988015692766860902956702142624812738029600777591216485670473359344000395925558440113",
    "6991919901710702396958427887737098476406123145888448373972832082249174478729219805232073913086288870815458196525696206975101995571932314828183977812556110313301933794619422590926799631826141146325928960207139220874195380742478976206248566268213600",
    "15375394465098365435103606262485648813731689610764786731485421737822834797273152493893303478414423892247122990573254606060877987088283776435111024652309468957224924480750725955516859522327151543381910863340521046671074079879177037242451769004747348970400726609",
    "67621699984704009571093949051933347323033942723591971420961654694361729000009453943349417050066498697168532312968847634399282360173446924966572411488673484835582936072259136005436901175709074663388020859582070981538504865993521127291316066926565506226402674272692246842948",
    "594806763388137870319883477715668014639530226250221334439268225572611604793566033353499885570285056724495531871328329408565766271788910680343753781709753839466974109279174360882895375331986271974503645690239888199740350163963394852863451796823258444580819828987043240094569439178005273",
    "10463951242026625501784430220079200349620190959855944731114436849579329218873388723507825365480181681240069956520124773793045889232629285007229542711667079762168429587695506277386530539600960138203196658268021421070060073719880333248021378799564961694860246572138977899599116168278661336912704319264",
    "368167554019320956145827862675510073905644855221586522560433473265572483507080939079705212086728437288829821510686303041329965427669398698246709510271765350093805510437355320602416018403182506754415616449810066582716483225352237188042691892487281620512135576613182207165052584133161253329646175586643485523247561",
    "25907488423318455274080484983551268752370543099016841024117675414780399983983209938035137269259009674371204242508318891176098687435253584276757950255770132597038125086011764201848182377132306683838545920270033915231978097219579884958727620755064828166606815073051027843939073260544912155301615352784234112764304811523137670964",
    "3646154850293767810262811310292554298146565645867019354649585770004790633021626678757507253398244149898549184370988858690576347186473540946746323736037745650406421052832928165645966739998963516104746895198985455779234103654245359809834943004622380945022596140552216033662342758507318222391391091643172310652637299863290964708434648345424161",
    "1026301351570055077911629003334248563530371464014961160148619401207592660556077047093700278584812110511775503329505399525951272382879961842580388109766172185903445721080425066638767951023848346841383603393314410107638111227747234949014648614460507172283080648297239358958028751902379298960588029789253841807791801792272754750610497088659279402182443687360",
    "577756298062641319815321289100079552694029634663057875273943785430800384531476038109893895203528476169905479147990463891771969343302575438598105099018502424124922191666372843671990452528625848668354820659455100781798687574206844095861604418887897443012027810311504846313068170762845168681143809596401125443319579565431920928673429699359335691054904647627111458615258081",
    "650495762166495477049126324444410541525813630884897301380979707413679252867035654462271627698395461114214289022287899099038885330170369042401480942772062910670199337987248234699021555821747253111028515923539884193597708437710312776309910996429530362900660431406155850610173052290433543360921808095902473644145899362436027878169512233262308200140510593081281143119604723908380068185604",
    "1464786236049590434905743465920939449363508612723489733275085975271232721338429531138219065841302235916567783054374294379287733653218841081671921098700170514558378605530384489817663192379350125532435243792130071255314573037817334501406125128647680690733402114935447084764720152787970257228537134579283995767379494435753562434054820219725742354492634229012108340533817520857573820496809319023469721801",
    "6596810746850441581553741639333517038709585890364844858548292276866814935193603264502336243986689091798809506276103112808369454137540768409834360859088738465923804221580878951022935129231629315382958142689553240242818792813478886053564867108158417175038867724664809956107279132606082421193307933740445718316354198850963406276459700920142990260995375238662007665213674472311961765183537934747223463590949116578344768",
    "59418788842699007286030480484133660884873844970657116918672826052315575217873342407759073593388395868718631808826436996552918251489892863712708047464715584987953212870952381722251151630665825871817437404434940589277400592674849493518878205551854127413417273257072439525856730376348151662087524441257956944276113234081656955166759524007873827433382019207030381963972246993045156494510638693753585551476537129107374280888803464454809",
    "1070393741163144887106615725527983485123900327163113842327624473615019139490344817603117153858127197758222925711459724942607537356486960154106879151377124831554692131055540711435791826303525544435084503709686020620657806411239135434299652837652142334413357256722319414659283292220894140424217290182597906316368285988028905279181116684203912641912268506780276438686727310659002549938410585160603678477185432073780892588038226378024952743251982695604",
    "38564998830736461475232360560247842901295105745971775440696135010899885298362813845775680945520056068016359115318259858323400609083322760694240259239549568463780365174038285822257695909831049614979140376577861300198438360978883338147260016684985389436901589778117101913784241058455624626480715343998372139233079163492506057596659507988170740507862889097554357289743888084670790016382465053400438597926206668478686421788457495335150862751345259046904921688545736721",
    "2778901029818375590546117527114822833083253841903153663407293202330682354893910801678157678683711016787917227096257185870640193093070699753834558725956305747107538616630061275380656515610680186080503365311822964203277178367599567092774529887880237981396131583384921472464642874362720103516571575280501129842510328680140775471366955314487966622218587227833476993001362183521295649903852714271677911744100104628235240052844338319226284973732527589283770792408791230834380038791712160",
    "400481844556464920523193301963612210459645292252115579284594784683638498620830533586843353519737678332246322681450974227135732826222781447054824568948285848784503939831712503444206649814564507709464166035933585822620726771882633974912135897915246868072599793241390944610202413878391697051983068345048030409259348173432029130486385964525127264545916431882632575945486108917185125511354370729736139766065701983316942507385259834815241449856185970712583942074007615935592080232876443265428056629447665",
    "115431032698441259178673461431544571503868580018940277924794614711362891394725324650883486562381578285858228647728394726167590461972195281383015292686312477206278430985089289897799375265169457211616699579674677676069197471602915238481146867940935761265218364843432447486642018075182372077479720231505523288056632903537651643918165537976430062690283601150336033705604323159124279613568308518389215883616118655031313112374969090985045403397061125218680704695227858031756178800640459740642742756744225156507810909338948",
    "66541459948504530753768001471968667858284135409681724401529211759996954518451120032531139614225451493238231251532753733701055189842109413048439370020510522092871615726466341176313330049692126142040077571310209189414710653397070543707621702209667438403619575777366609708276569345859176432200644796894842211071811365074132417536370239768267097010140225383394752233663251770436883502726797657416433192243804494366548997794367254174820384247578803880348969810547890908371517261893224212909243055022533467235254803689765401001895961163001",
    "76717080122566093821769685096126559772123311624029237723465232813219038058215332768726502296650001326838250510587004733662016375013492953191451633671991930832662056467300994500426063088119178442252586999548057321448534212734353042686006343703170884180509130855894984348299125158647025644349686247733683852902217528484006343325456330531420273730411859784694088131519640808353993255350982185668474147182920966679606123864658043773526365017771144077862125855846520085396629984612009718749120108147731334597235208266539721603244154875732409825161040372448",
    "176897542887905871219682320710977180066096412507148130144398800591993075904013117980881355032801406588134609369694981641848153852976363677785544097092613770281818364124632009850706004125819990850402116952706073403325294541662034606811830123773348405095759708577893534599222004405949196660971716404021307415506077181991282349212625416976352338009103939503132620599547081657135972295238300924743231563343455499431523445127628582086163262928195106997271651640503572591551555564786896642694309499816136037740155827815220465607273333199955313101978017147630703180462437846505",
    "815795925230314728472279878236737235107487487375679658828359306005781952327011641385077044577339321765600913052762660294769820791770837231468099155402135727408487804724759410651567753149801583823491121663182746671004121828366325996683495336048610111103062424489029445610286346390600153775216536500430336286066264078744202103042898403387079868256073409579258273301091098732895412193763509971007357027650773056769253639107048750886569923068217313381516689017541924361807462712584927376426402065014205999079298496517051180385541771619470554470392299140576693851946130187364895826304018436532",
    "7524389324549354397801356452497913671637302623239050243751095468094073323336858804077729632349788033524157183679764253462806786929408221296937761659704126588516687374381386849405003977412109162567517683326594397687478205453084880131365490951409870797616769248976328676388931788505415601925973590645938499268262541049426638074456046768014363619822950195610040630933201569329368868610871434945858863279507025923260734426290801693454566867552748230899663807535422195912509514823638633361081868354837922529056986074315862782194950537772187870823640874737638254152056104507072694881589284940537679773850977072513",
    "138800484180914219712302326702802179854054812711075261937158556233721310371465055845617816558287345197144834244412133030562502074358385172099790842157457098300290240620772321168774924367197137494373750720538430011100673474275257245459737980714253280751787852562489002753282904223588010757292363201789356166325963714199767590418631057996650918561431174151900925134507597012978503880446863326377786858774360003890780369138234670418407251000511351628293581577299348828942273852930081493093998334121878456629837227377524106120944104925125633020408961756192040925542629667073721808448062405693069524542931864314469989248726628358400",
    "5120834017984591508986196650065047875839302139690230205242731029048153165740958537724634691687902033081125674592419026458254627254495852937279629517113718862446297002364410605932538889575185387110403381392921897463896843880158994290370834895206784595764683077936530808005034896226190751678430723486097603413102566255405706590724427432839018811520524940915908941925941616441799147043105996059579581399762915510170502608458555685663792846861422948709937177633644526902247207455022159988595345687209029887264778214048887740257014381728590310929870503185189600524464264715439643030705301414713636766758142946557851849981598413774984564875893507018369",
    "377850858294830139838638168215802093086925887126931914612239873126836129796244799562758422809309603708215849432524255419354025814001205626509561108151321750366199545761303757397664868124520798866672006744344646633049759244954763944237261894295515947951872937978674631714166544336378239483772494537238407645007249726340757921345521719083300199288008132309643236387222275304797366657103508197721167962220845749586684108873865711290056515696959158068615301851039665494059268870959118844400920356175705157687380966720889833894243511423508135705787528561412107022305915895881489894906873510821612024136018439545297419340176162703185408054988474237545125776204554493625348",
    "55760944647969803670700104936214276715083423719964045844661261136735339428078824319189106889614681158954898596838282568639485048074403495380558796018868074077602263361899920421103748234913182376058217018138234907077472583680834554738582056506298354692633634463392531299779656748976674976371384999803212355062625627460199754811512752517519048756770758692097190528272227779398068312803465029944309981139772352453094629307707229567901268616831948968968861245140912561275319789356810069135581018372862940328245978111483249017920767891515202190649900368623894983165821800561237218954689794504655471024308339716120035480157636932094372754055666489367370857400174607664955323372432165991628713",
    "16457726003670133055417812568315364738874776204650829760446867379357100901998596163189085053011218554661644549803269856525188792881047184595210714352756578973527862632628635450448100320792765888834206529527729660796488455867210791450395977508040516535191832862845015654569350215454316955118222039806597866354046383808847585182860266607616032250727426655837519195150481857532035866993409781517191410369191200376841697867377706846839050865662218445357651122690044498843915087410627989921449147376211725165424119880416167530131222904526850926162389557454850937419590150984345357942390933379521293123703350217335856872011409015949731998936109284855296846553605248986483467838110639430039905702935311346728425984",
    "9714926707998003497718782308204867881391995522576166179966726639015271734322741879515888403999270633009456307795063575324200608254150961625977536212788672358155695862400743508802658747371648724305762715776510644184132781329815716389636841942054042750187968040558731142347912905856633517520416975414903353968386986895884319388343436738813313758188795172338370156881453176133576008505649914226540367740759685387036950379555032218800307164595235996995809883572745402667053885984438870804633299529582341664408861351121721896556865893632820313720292304173565796111051950884073273595925948160869627687226894060248037636990997764710602326971142383930132194687099865887079304120122599822733051879032943082681473611650427389770073879481",
    "11469361067346228139061290587410929131617912017229616968931879358352712132692730670017732582915701188470440682798421241570649369669817366523857208399300981386889556940425121763013214087628547485306494656730035115891260512544628932970281367776688502903385877572327379171148354222095807317297941530351533647839570093829501575960261035292986369272018255979790767333074665187640092150108236079579445516397459018527194007478060544915760943720131722244888462270667390075178367774793424587459442844723497217956347252093999239384037316641861051085362381919864487699185619546779427201751377735016624998377592182535142708053692202371925948790251266234067409521984320697646766468453266999174807844568415371206966554740279907484434123667863994620867616295788084",
    "27081263142182923705501438690346729644391000994556618097884319997594440546275851690598581293011138241498216941263742768887386257721755417044788688804259686456777523551258934629081827946316506330744983439694378434274048288668616002057123700504248726599111005137073460939636100761717496712707021962566676510027297461544395209039183697769569007803026573638424565301229537767692312612739034823349449787414239341835961675930115358575277917407475478220113334514860405650606357677866220699585205914327814939292945788337768927337605491630645113053275649354853796409368920413885365648787908857425533690712373002664477203262730983426254139703971283462560168028899012842115614571845988010635474336692947735667902932669267724448985499785309811331912260886166969814393907986968451441",
    "127887649376417730093987279874959223434751978727177317678468933940178567670089011059835936855306476314055820022674203070882272006866498235564667897847245117382089387654340603395902770656741171358357134677847354180571420601614467393550918623550656945327872955722554669944877200644357783679461224972489656883740547441427281305618936723790808824641823096775897200607765224286457542213298094697818489613158537646920523503894561336356839674546741819864479496248510271493441660572431259840084209777665340391240652659473135136097045446883084078105707212339046189421949100941421327954128430953596884962081660467610278091053569098997728342746233647698373992913337394239908249503007665059415775830744926085621771276480324115145743453585347720689738234722350020203302166294597477629009148270254213517280",
    "1207864697976360344004012227247920888639870556218869352974080691964898302127728276964021939301689941990362937010553438022125875474910413432901169640664817522687207823455334075586484183617965390674062328517488830061205194043831855389128743458972541515267370102123660769648254278386638983308451584920187102324892012358662087067501815490945102835113347456386876024256245857607525525014392450842298842561085780480862959189074434916476731722039062425413389048213999283360212407096664775268828195424825259795196195694131392781507276727799638935813848554201384990724788235266234388995002182790184912720977359491307710775394369694037827284801803282839402462375626865570762358932992624686869050034093558722018928029072089221073685366742978097470229376622034123034422099304422319858140479626988138175771537761521969831437201",
    "22815919062260124281152347745317946282499934366452617323776006107241264602795533469570884875918350525205216474758129727531208112701840870980155345011181027773422852933990746300522293714126974985638485168039689385550418024968764272990769098223201120182551977096018093416278368986411387333742287512369414451842816251894030991394790236106628455873678591550918383296249145880035684864657299507214594004867992875785013148350540591071451041583313849078768261208274925233825428798625787521636329116996915481986406679365161465772333710190212707072662455444363658664104434867526067652111712295388244910679090994077323162834865184640479709762721421015631534282503359877627737619631152784447957572390295086881759199902021817549109735688232413009794162499788571838410692862747576101632805470237935435435032457070958135841741709577989566454148901444",
    "861961051643870695033992674309167199578108591679622987837512302052086356621039331592328102938527944006969148281855423551800084990342049021803998916166188572168974831943359972509780724136928175759383402721841125760716459294947775610490628574824900125739041644401488932325733698598889639802475128199627729041020774307057592344233262829078520106490200228690324177346863380651577401635338558708627761575924115623526976698616904374330016894420538755305978253349030126215039569927166132767152587499208884052990255565244775397790866949052785309330648586993446378470043418560247499529666716748099487358255406740919234377397521228466466667052177224150783607653016434502074074229063589803728318964580759649227631056344754826948147040633057356514591967427146922114501946293995982078942839207023798874794106072681931833541348794644712344619868391140591142198044497086681",
    "65127935677153380382865185934274607003810026843261289749028099882035397266927298241817812280663338302874592484963605382191929029517815698833222693542915607070266553275714496391381464772501142599806860926746646513618971592205716364184090200021765814487181840031669361985427896069354939545049469719264201514996021534340706619059408974513793777729755417309701092583457478222165086342915655696255169286054185482239523506595790508483403449664980481049058030357857517104250573057167895059024670228186104251358420028115457281328396885572060594550832075624058360805811294013609359993110765379657396709253579376411328711107823334484055480885887566502155982684909630057066748521164378750164702530401246959481173856699170629438199765921810222285786020184993912596568984417599237209783727547207010554117928212476081712087104049595278383972168871182521185128394733742058868355331729347802375328",
    "9841855377288937415447390527231202153455845092922758220238949862370951215307357850537312032339475860155968712408016460823626898669634734193056782471951119477621234174959245787176440645022541201418433927999381226748012716854141806994113738623687074026055728022039803451441963420176933414863295653601443369040100621994128949157016855602235530478271371783778599964837999796410821452366579975122909460158599665128397516750457000925545284188367509819818312672614995954226597473669410881768891599589399459286861164368425111556443211981154769056006631128654366273403403984396497518667786872761458174165192077384987013707714579844814595258260258601581922276564774352923437301971046177035365677451317202062195855147979906365571614210834242853829168695680618629448477461066172682431866417173537080652678408631229103898584370370340075955219926311960485681584387269950648473511141490698746368654708733477789568107529",
    "2974518269629418528183287790477136251735910745786981274890992938532906530868111729107068657934012028612480976341594884107864010384448541500490865233582795689734439936042424683138897599808168879614334000309507721052838815584185291954320514397429056701324964285255443219553751274822794079044766838240890836117682480710918223130904823198643091909734853753891122345761054756585255911176288018728174195207349536313414834673080480696218828470267131454399908112971840743103995767114209129238335593662867811594910126306838824574019819901335442368728398853720994383348716610307856340835297745530580152133622334220617813359080146607310450851945847134504252094656702933493785736495664926424878653684302180250888370122424378099420182931197150733885239575633998226054640324499639221170970571837196500782703006071322551989504100597618920993323538961606009303770296476041906405386457368270312607818831683956052475175065456853992908617662362164",
    "1797985968535216664944496004358374343509215681442061471412191560717902567100922783048272325884204171542595289833292525444657649015706240748603258905587228070218364321463272748372578381297752753873677472254922355241777152285815968419478586580462607181532633401390493324158696274873236811462980002924358959014961523858527582932580094707941486443910926176542073077556968436127272895058310597583607027726718736469175668307253909021323053371430188118304785898711275203434771737000724872573886880637420519724444463284443388727630283664666528052367541776313661585262983733024993681478681073098831498512514689575760815626512236554172414169581755726459092026691025970210757809328265617410698278014699792075882575574349505687630013946351950460669539772156003437151693004013771313802959350891175251984857136050528938291210156109810918641191927163139067163195482729770659833966232718210585298243545222708068057806276615307574921733035321516850527615134840300065761",
    "2173631660667039668984700210504885053440928940865456162564402194450192737785944354406149109588819094440916452691813792137523989079778661039306847441699924537987002272505065952351909044938639225469091991072478833137223773687819006461621204772108114730273468906452573994630256815525563890925741644279532588225042277283047107377981352812637499200674264712422200295447343469452316702920081857866102776356345497901140695696487346008725214312749099478128927072045696712743735290203702331838221557958853932643074387803640656981902709445151878662166871673497432912381776428661932724129079887279917188148015902271804477794216825082799097380785838031970555158952484840972551708876895207352306354118139601108599277331544048236856217944241990869613748482221644530115368470558860568500649731583579095495114437368621422163669980345062271985618577262359687190320419363115863720006906825698877493420984150753814464314638128629424645115860653443638386537575945993390222090061534723636118094400",
    "5255518873824416903687803876194048725247752904679834476906123160247588754923499095648962836677062896389080005777353515615519961786082157218832055572888104161960813075858753993204338524520606093657672316129670165486135854273027257869117232701486901401258470698179259741025577761242213513209255265386075016326500704930422917303642525563809742371542797071777422414107565426108275731906962485919752927196293165342548870477021478900400538967825706071178259031122562772885630649405409703367063847618824225741404842134016281294348855334227280096144669219910062498461347541103272529637968942509749127923247417152771655159689179823920310384408639369149430628041096138741557302442746205743962009461817743363439735661682176474418558478862493717371110180296141956513429423626802848160777461681081887783450338143596074005845010139812966205263949945983128662552765106808342325556201688032318423379767219146736065666134076960075878713420750787264139595997890269239370766654408997014349998493737638227676461278296865",
    "25414129848153344382239046897534255136864521425032321543198987907463603636933218550392121025284493890288476740344333852568984204912221236407759201838250043094916016054157811039050384830313802498917327099332219522477253430173032775561934636758466788137834217723144145907968824485104472731993407547905898541493120018409937613134760376879698500643884583858993728483460548847954890948247194125123156095375672980555831310674187654944817851083192404508910514298921974869820865701713490326851897813303945393428361416466185302188624486782702454447009759360043318904833610708468456173638563883609569148643382336489258542516560724062016770966626698695797368159233954281229324666488409424257496778134935043856989449536834116057893033303353457507584758178817698103932612119380289030912912789724315249931641899025952354394580439332837701160863679710871325897824748698596768252502179281396647786052611765866061115109191865934621489011713077601312587981937799725560613800545479627509110349431680140666459693678259767085645658970194741100548",
    "245790382051771145194669866894836910650556797257914829803716473420465193642074785106013428431872514878990588535214089805784162788716268545507631394966483389377824251794209196910779810599768510817296027140745794488967813649665678439902611015372568414560564837386564200026316322622469702182920141771993480749946980462955772899543665221584443658493203555840320515400734302189586986967099083114722544095624065532036164098694032656680024111959698488163186022307196914667272912493407206499660416052003049943320670154037880892156250480987107149816211161309922836295087659300508618824687956884820016773631401885196243741354255718836847763174171150793705155907540422343384981698066781375095240480990134676009769488251998070721441392253598523307683210522244865434657081035251703124064234955174647593539899199148117815649511423125305933498893595052867200393735244911155718851795088319566226103141215126650756014289469963426812014573525508734437947623293924381772567170842571420648049323329611314031206248968085637730764688978260892710185319163536688673706573961",
    "4754277425205284348419700021630306277819594231324229673831987127244063117828729566892466780545292931445751064132598220796049422574876174732216148557133667232462191164441022107679344784650946278308912307973277903956268576892515252911927587831450116803526252393895586426372864009992966115390852936394750781294322737294890737473525184307578815480810982000203467714611503183864749503859311439369828005557164015199013783918013720233618456348774481774753112051446414232930710030976119808826827308506073570808339673267387683023496924539170243992317384631547146462700227014797996075472403243782366190785050806379793489498063712874504188420861004661215505120695733479355193038519224515551902148437215911727990794886093643859520777829262246056577527709508106166200880046179677051280042398448534373860209884970034305287546941954518543200553070165755934934900741326454179854858073793789736601021130950282124624297415724072975890792908593463306606956627920901394037442868832942735746785658082329107022810561107464556051920197082345018451191779962866090671709877436527340920295983873675968",
    "183922199454132071495017823964418310581035406573285867942387118971767980194298669452496073046095672741192994977719446859167499481046047920511152967992507131104635352501375605724763061219686028605852686640493918295524511367033919258002837197314997473688054582719049983607925090921272907361139565610799991114899860297072476759703865254675754657490246508692183159765565344723487303603711859961323554140489731309462898309371578604489888860463103749708952933574490718753656978018783870841450820562082130138165145045826221457571999110137620197476711946929133441974930103211731301956168120310220844903461586897667281194654495842901516450393315112333639568531819418816253828855234056983083196351960519615249446261569123498616879523185925932176605436673682846349231630482429190760052935392649605114676503780181299909265803328884149516749748572347513130356923240327932454233077107245936592487285276866022784349661331916838631589627289467131249951961851344505496562865374963461086582225094977839064589597294458058553953404775061775900220028771982319110946073668250745512731634162047449025039426111927211803995865",
    "14230290926106362696122823080900243390433637603755791732106949911824080136101173014143184178281755137808174552832237606682518767799638672778692076547632370358005439458077144738842032396845315267717610617294892822173762145193043842974224805316879277778315687814683522725399979743956595259503780055472684548890238961768208807160567892770726623877644184431548999114967406368888173098282968909370845628866148259403677260385850025509467281073406163010562422645627803366939821304123828533395816659998533443169695576043444647330295513146708544008976157838105505451978776436391695567727588348599603773574802620015774104832871364395667041616614771686179713187532904193505988616414335011854214967302674800073176611175881450630432052774052983125556779718330138080292800433952456054032604266822488600945337656930977422163042584040081079715202559559706680427810729697183093076120375394553687406871735569061378091451887615270980769227439468566974482812207090169807970800161198806613558092139707938986543418066573554895535952384507580101084436098279822868443311979821043798055570372960278226673257921008509744193100971730800730506925391420852",
    "2202030863513312636321648671199054913516907653916821955870583657901629880180606920851316146337288935118727861622032224661459238388205429018685752611395723406547479819229390443492545797504661380773345416129726716459455265974513051084690663766875895512050711716295351874305222446226840039100506198384816983956044033910816772108323723191473352471490019766445555662599260829041365254451095404874525393854860088562237603696867168580981335357752085057807386342652570530409889131280895083102139900612595618883305485831671937515851727719366610960217159502965547519571213326430461021613875516598906241231892421791060695873939955883202566120966832952262431203975372419316838357685148234821833871554807736150971283740236329234471508343336380545366101483504448683820543739518493001750765645016927908145867820020571328279082021459731553008180730370556274578694992229443829530749361758523455102029960626188230296817428523359972347630927768572449727408126679518786334760290210092809432835028737236803500857663167783510149001301787146724001281345165332421763856992048047543805345657733242445022058712346111512565047505577553789906861865019392002473375004108968822887633",
    "681495543421322523798250098264197076688919625958924143870524623324155523045800434813476592642445682226654826184802698943122317776841833338092598992418663147746456667907249402037063519379241181043394719183934990602150909864499962853943798954546734361672671887789880268590454809802177762074811062436474536759599355302791778103928706524933039831760341656418460923310333097321422326655790770169714069442364061933201925383010658648887985020090047082828195983869248452906413448963793515736293648149917464339086854764215956144973338915366660813493543853568390289459916851571145319967573474741211934156923900710615862681647275208971707741861066631108678884356786881992035776409585052947098823119556147809480886651331093987482201967479673551047442695482802245485679248334227599583694833975961971137625665050598038462511431613775355717783643905026226773388597214461766172451210480389402020021519566392811355446826404040065412029215892009880106600517771803896912132143410644117696845783765338037373047653977544986212864680486485686451440775977975877670315582767354407568891763463570492892025606839060365502598578069682386408871277926851695621031183293644067480988939694506298063480784437280",
    "421825309897901792033244672821110328299858989707329623198351831257487412488334150494408358062816384341037383890227832980404741461220678261412609915977393831066701003877756508821161903070536068208635131114822767581994507882764742445246380739342818553182547915925155331364115528691522809563388981168206941607225330065103786153108176871916311445120706067211302704874795861931390169225107799497180298591712826442003609441599723740839388961730892111082517697449982498960324638396980281855454578237057403020373939942229603634141735998842082388658838322719796042537746864579992961289849549899511001649278962723352024945085436276706265598724392341910421392033971774916402350499971029677793340329156126649226991019553199138630763430518378475497218698611778946297639717590578711188776811067824689067051439712055550135303082230848037754890247653172514796418849183696052210614129285622581470276315491615583097616508138593473795306651270631441602744073414304619140211197342049963231681092472420677397706114111303040207460507387010163534918325843816587622873753721872270323771780566351683928591957477943840000397869341322941208638899271633527130479967565880350857995127838763198875305079831427134009943609689889511097649",
    "522194440706576253345876316972208990580919049498423872746826556039073936784363111767913805624652405410814719732081241372453259899769610465953650998544985761570588885297388228027224024031605389917645712482238686849850374382696024940068487090601971453157602797885922894140742111912574290384622150023438566954059414609674378500664586843661758940944355389537736955008473536688538309046200611172778929700401064225043636279276379216513660776584651486685869128560911836477979733407945587275638184736643835546830706430899815879027964494708699156615327858162669162070550631973721381397788011408835912083069923381578402765996750824350788845053399061457299376594796115026308840853616135265592537464404465489383421079888172068087880540593531143179902480849252020994692799211507956931239581512094421396636115959264040566880273454550352038397869100839214271729011388765517219855378834014619284797588465809415709001101673998496791922662152269476771965727632789007992832670675888715975905568976697604879351897631215007274284947678568308245009394733712372795492633801227226263715657397043380945358953683193593708067947501622311488022101103980147119126363144499126201376612047565500853066145133686913998486810958359950877917878445430245851063764112708",
    "1292890812885812375326210375759313154211806521142433468922887162821869801398939483488753092582940244169895415615723529137693835999168909478836520004604853756327496887791785853190175935817969787613007017072802027259003595402186993800697661464568400528012281699139347495744991446527255046611529092871296674138998156347554634956380096911385722878825122306943446316918546919191642923691382707085034138734478154231047435426838095551350329882938333268204120983684263739781589379189335962296601804776669491246984049532240711845685491900530145868474661623354280206787303545194909034204882470344686919202399217705521889202822539656812734560692344890265720007935961860978634043066823754462315724586622906572368322076593078378573258706724878413227664591775285315452095921649733003420985540281224033161079571949877521419543198682221165913014564673144326729330474079791327266883866797006364248513928735630452023998712316883707497819926672175727274797214392355511094024173454333194990105008660589406039840231914887962856846223883741599628656488592860277915422435916707302055221333097465915078656577855576505991212547407099889092520973802232030014149824651964729064239775448265753456660102258918124410545437419318058981826073574997007258786857900425313073864419946319752386233",
    "6402085214782279240215667419755299131524078858723657506895862975289688072387184202724942636448865634845362376411290892852401212244654001278874518493614983067502747915241546050757364309424213614103351721121771576319817771208871899572878663307343584498970392022461500167705150596412713025498564145875784471053079814704350338683535811375085030027987750061241476586128602964527699150059431494402589221308951443361874895410104973416993861615687357815981573643523196453166411262322669063652215755817554138450872251934892065788022574397869211263348099194622475935309330150491581437524740673066131732470626645053686294065523193267056502243594603060514277453776404649471843338432761398643420303447447392526544300501360143620577982837160675633127966355026411086588671293729638229729527350884124362822005799132185856140189806022064400645129879239247356832489836113046877006982810044078806260652871255547861936278616735457447659757370549778589309877052296555146453306216569925238186184545948010760776752863577696731293552105858614736089212602430508775892091472061274860877107264744000321017801220672792377067808866767300805984534049748959074423828986257168568315123767970931003629505434577614169221291986898163677106670280470593719009386913071875497337924524806796105577346298856278393890738258162784",
    "63403180978367415821309274946297067883877259318587871831770935303759143784889889554522281287382451910266246973649165784240949940375905696313673544571183835877544775102679330229623874187057627911328491498254666556244752237079714799807242032998034747080435083421456527343310504382222663803588392283156708348347965214509324334142435805184488402884030067350763759088085634521688221048465923014812288980135659107429338721366072771902177317331209923787647162401068528268815851417366526556579473672902061731413545507655314171848610980208852889160305234255729107360455608917522003043309019763102004826290162656178132172956263924922033921614947970445348142630509045583712683443705086720483929437220048017791473564742657116947722369162920514495227315803152463784553568865429940343244212964576831905347290417216185020746795931559459120847247675498498645959053033467354700504808682133866202321576777637699610952306621070917464876005469622251525837775124034592239768060539773673166287745392457359899369480756958601924929019139335622884917647427295587394319350269985046868723313791210440878676771219005721179901592011590792480857752380663805202941662193742633066453665435034412070612728436972875281797488541114694801898068329538488106826579312099461616252171158117928691489532617400613334275405971783862885461084050077409650222121",
    "1255829381618851745843939813162800704298382133625846842809887027840806114425442788432951756305688105625584320996766594288880648101661897268608898452842853091871430074406261051662977763444204040314446476827739540629381287732437511633979044797505653703284996755495471110325074108823829327334259719315788979865719699690209168910499796869022853983119683378442687424694484609213994214644163117423375679859361851874945135010607663312467547242079980837107518240180188095688088909845141420363857254970317996733152619312732883288975490464846158346252555673689825095381867952755172907391545035014962182630853114989372864228346210416643412819423178788931952792154650291126173981426167299265765005270386003626839058749496592516028453586356025315751374536212082378005765647052554860956305529504456848719889829131591134692949475732263074524238685056826908312615917743835792479291456258400769089722777027421482409406480004366856000575782773865389481476351927472137339199231525462720414838670174631594474762428516604475752406824356251742288326276053780533711530333448036790994099494770997810524004481984180613685777525270718904747092973861419430124617929024551387957508938994689846266901328969945717228032731721753647174747569406785196315734493280834094651426888584314870928280758447438711805507030796978914317257131734775655380315040374088457949709060323406004",
    "49748527168543236721217601181701787859412164184544981903139637413886823689926173009749595037785920888633489850813311481605150725200942772634385682961800537019407409724231335116010495734338239882288762420223511165095744676851614269111505060030202830914772171809254625804466991379578455279964765634194370893040321253131199955632614113995024839503107268683185453271511624877149186009028794740942374257976152320827283520702289642476092612689568215013410083893734947192085489303230326130694863051813599777312450947911799058630623513657322246356493268404069120290302244596009483727832254028256065346921203368387650764228811482869930619107508177823648111897705607039465400644420066304018366753528088567820681968865756929464873024598946240847282494784399930562460085398856729811420238208811850152651752608761853500956135953577192613531210110557768247940689634727322516185398423564950440789415406724110084003199382659633831856061317507339280206724017482266643331562198723476036919833153010102898515959713302712103086460575098566090065346768841886435182884860726130992566744349211440812240394669086569857277041615226621471919889719942355211112724178382788743327932844461909626480388458981536750884717896387957959548038505816970559996687017319313065634235402982764880377455013166189744092614648163441208002870528662152392858393457349994719547165568356833336692922592930108791093677121",
    "3941484395354638233538289175687367867592105475775706538454175082747236251603368256462784997091649148455366946998809240665068740057549963238341047848965838679076296559705812982932441135448614811939712643600113860470148341970566591826053013430213246554265101598505600371638196644174796391761347969938354273001501795107299950001230143854604149208783763671243543735195629086089987748497905953018321544810568341805606110449823245162286537979367516716974126102699995194153499320667076775730515741694091291363363682309356069378836394722968454458735596153575297675695696088976822315210976745126120449922477193462168610427107696654610352015863159528105808129843836325761309056043876921835464986748372647510317779813642129035884208182031129078568808486881146600901776816955427541739053504361753306065451140142565454704216189959009236952696539497194827933267863379467728084352141393853139101876405122893238481606303337295813230196517170933317260070226922872001550955906816786991421540780708064328571709273638037787506948065794383692674853711719550829095546351939467091650471946989466206787800253144476849912130133366764530496950237700273883783788535467810581022979050449183133839425991501245570487876063446858799665498721662612781183640249557225878758778467886082088153927340352344903586316649617911766321104499360124893158441628797397964835750827782235928721599081063011966538703959912871409201370874889689061760",
    "624553132445188374261017074910616651175684707033259989622425326240358320144011542099208148038451167451431700514902647991182094612618628783981105574369472406739428009809007136714553058225921794962678647770150062712169329741340380492986255026656442518371429178409580000334862736571441990986674246140792865699335750126142560573125811689357910538278846141003743210489968268151600041570954178853940648725882749987134406665272696932943861533879101499278995846852072231402899570043771700965384670432978304499197045909670750037546387967323149538975400711173599891145620098346488677369454411866360324340222789777152970538711484395999079545411339044327158327807169400718180636168954580274173073611891648389467932152813336674925480579727329789015150165985854407797204268053125510428920822155959407359562263600196189006309280656043497172517256395758191960803404150452638207990202239030220188321980089926698546009343176018217675542346175086759754685132342655920763271569764066995516289503374534409608908130909767943108219586731390753754077468746438635363230450837182856443925219852571666620481530300587151495003881755883253412188552627194665184018012770900376333616085976619651152539728779641256071708047933190779151063104030363960740539021321172497331784128697081763427053027679387359203428662165168474568024150340706402354835515387514875001532800708245730649453853973146662913949573677315948284445794972769726235954550989088166038327194939841",
    "197928788304640974341464850666479258600695049180808534143893236720551086957316991561782895711903503838312659617199847655131761668521022449864555989012015631874446585754589747562518909260670023259069319536958471520198465354731842048373873023222171792722582192051964725990900955954401448459366549745758080863086574922147403139565206738378168498096710925062068906793484169946458816934858602016140384846517427368813953275650810141982449881467020943433944463398288043606587087462038102278279333061255778743656962220698369395031741439052192865217459034931482198772374534020251547470047498884015412872036286365339241113916226197259801652689494146413056304416560197135553255323166738579115783454917663175807744664963181478476800002199479859854322683267486665302827350607612789848121755768629588114023076112282852388119573593615140664063262861889606326372759176465087547005139960226174015127321160586440204286047417005663168199250591318525255630866093314040686043735008459820241181974789900146460102681276064452613697252784678683017712816191077024853514258747314826689315347249165716727109722988882720409288376223286292825416120602544160894331904255524723403560007404728082208342668783153489098310289106335749629363553158441700848515546966661090972068991700585522607404575709118157718817843518523261561387231271221919956023896017106863850408710227866272943561453555233934401941520039173466108588491694374886570252807355915262126068581462067538865007618041416239337699844",
    "125452273648412141401139200773089339811437122262323352219553824706338070079923557409066217434882229680595996502151644090630971486259294285183183633129649272779309737174395404430149152101788835053861027104571637543627522891316511380301059965231787142333009147358563841204157993106127746328358011951843945908682559568647269686844782515956183293678683885808384414357761866799607762827058739727381391422081530702944284229892077009503570529836320239926968983078178452050828544077942799110265473616548265593766770014485779543167936514534071393018643375473912199117711676289909272033306873945015052404415032999637682634276912805986388447581835931757690057967491778984101821758663878487208247496763635588487359668638346174665417154052574051497006316330964451571627090453129541171720163384048314990787373764160610201262022979099263676893729850702083728532270947109288584340749241139094735237019397845680629336068461824057317607692281274743450322416416273792937253238782600748928299383580612411844775355999477318876111254457008444448966213113526192151409811100006061719887712487378731078450058249337327652615636078868903439786623915180978846847634714364490430396779734368064214773976667385763118747304181925067171954039707710176623935170213676028808676899130160613535644211234205271658535891310751900409184176834728722957024409233397336875992174922881569367577841678674683131358772093085604064212778055519080477496486004191899852688298187675392154348091119909214236284341881435549211816258307298573161",
};

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
        cout<<ans[n]<<endl;
    return 0;
}


  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值