Solución al problema número 422 de AceptaelReto - 422.

Cualquier duda no dudes en contactar.

#include<bits/stdc++.h>
using namespace std;
int main() {
    int  N;
    int res[]= {0,1,3,13,75,541,4683,956,36128,44037,28141,3507,39367,32190,42417,4602,33803,12795,30990,6368,28164,37196,39695,15026,41768,31125,35277,43596,21934,43334,21110,10919,24506,6107,42234,25325,17116,24465,37231,43615,43854,42524,39419,36919,44683,8142,2923,9900,43709,43334,45177,2960,18115,18992,2540,31659,508,13355,28427,24181,6690,23235,25813,18942,5316,5342,26501,30262,35237,33871,9494,15418,4162,8768,1000,27677,5693,36157,42267,2577,42724,3112,28186,24138,18478,4511,6788,15642,18591,10747,39745,29387,8064,33956,12997,43845,32621,6477,5911,8154,14232,38132,34688,27015,24867,14959,29462,45063,2466,20300,33180,26393,44027,9027,25545,20398,27016,28683,21383,33675,11902,42552,44615,26907,22137,6730,36273,16407,29324,35064,30767,33932,28950,40752,37856,8872,12655,27666,24350,1661,15355,31887,14534,36532,43753,36970,16871,857,41417,28791,29974,32954,43135,10608,30589,23186,6816,3527,27550,36653,43240,44674,34526,19845,17740,42765,39200,18513,19377,3708,28859,44413,16481,17260,24407,17585,28741,41166,15850,33385,2681,14667,1019,36129,2701,36821,39433,186,30493,11163,2409,25337,35856,29983,39560,16333,978,40440,14680,29208,14629,23888,27854,34721,41097,16445,24477,10108,18018,40602,1882,34837,25400,30672,10564,5505,5269,16123,40519,25073,16332,26842,10234,17995,33411,44910,24172,1232,13311,30412,18417,30108,11226,11828,14845,15138,3935,36146,11144,31633,31912,32426,29098,15978,1980,23610,30009,22839,4017,29670,6229,35548,26989,38313,28987,8822,46140,14718,30909,210,34599,31798,3281,9630,12732,30024,24327,1820,7274,32223,28552,27624,39824,15850,30102,34121,19883,2727,9728,17345,21472,45858,30532,16403,40317,8558,46002,5115,13219,39032,45734,13221,30984,2931,32678,11933,24858,28322,46224,5591,23868,17917,20731,12237,6442,117,43214,24275,14439,27873,10238,6787,32553,21514,7976,12078,35268,6485,9496,12195,6698,714,30728,6293,28187,13136,33384,14431,514,41798,23738,17804,8001,19846,775,12386,22822,33682,24594,28661,7957,33447,25552,40740,43634,76,22590,44029,19340,24620,42740,45048,4871,10595,35279,6914,1401,12774,16345,38509,28372,24295,12682,29776,4441,14207,29240,25898,3742,44805,14078,21944,13665,11947,28995,4865,41577,10554,14439,39046,2390,28187,28661,44846,15077,25856,18902,3262,13726,38639,37418,42029,16351,20032,34292,21439,31655,36907,5039,27052,19424,39217,14801,17813,10027,21804,21599,11003,25744,31291,36987,28869,4013,15801,31221,13995,38749,23762,28328,15022,40217,42391,26302,26511,6509,28648,31246,8117,46321,6487,13729,21739,30768,33512,34013,20962,31397,36588,38579,18648,43261,31598,18033,45621,12361,7738,28507,35918,36823,11241,5631,37293,10928,37758,37196,2250,34994,16194,15132,45692,14398,31688,13462,45831,19243,4768,35836,31927,38198,28551,35532,21684,19296,11866,19874,44609,21169,26097,14859,15127,9450,14111,27657,36674,17807,30069,7483,44226,36780,27996,14290,36518,30637,26253,12157,1379,26511,14298,1995,23404,7863,18412,9921,16354,16423,41933,13375,36011,1806,36299,30975,18250,26151,27681,24756,32560,9281,44854,30081,4406,29476,15313,10149,17692,15488,27646,1021,14166,242,11265,24241,33804,22241,14351,9069,39660,32070,22203,42503,37016,15613,31389,6249,7686,31105,28681,3127,32810,45369,10147,27624,15286,15808,18900,33769,41570,5279,19954,32562,2238,25856,21817,24037,1981,7555,42810,34128,8239,14363,21503,10016,32922,14468,25275,16033,9165,16772,42449,40837,44542,7022,45773,44547,5469,23329,25029,5631,18337,39212,39185,3056,14370,10448,15168,6197,40617,36424,26513,37314,20396,19555,46281,40865,13856,38514,5693,26658,1139,35355,12946,19473,18020,35989,24889,24702,28206,40852,4009,27702,1446,13363,43574,25790,29776,14159,23207,19193,9061,6382,17804,43443,3641,5032,20192,33729,26675,13485,21651,45090,40293,10288,11984,3828,9806,16074,6284,30243,13199,45581,34483,17113,31690,9091,43361,10111,32120,26347,19336,3308,16363,15794,31099,45009,20646,14447,25785,44663,24211,28960,5238,8626,6006,38901,7432,32340,31124,1994,28654,13980,25981,25861,16594,19310,8243,33049,2898,14281,42383,30967,23436,29000,33964,36420,22284,14957,12604,35454,39418,25878,32695,11565,10487,30100,37787,23840,37347,35540,21061,38009,38946,12815,2818,17744,37924,34235,7304,5841,4370,5088,33086,27554,22491,36573,24663,20986,41414,5042,351,31757,29042,25691,11000,38336,41685,28969,24355,24124,42613,3673,2872,1096,7886,43809,21373,27491,41023,18010,37286,20117,24195,1932,44228,3131,30507,34451,23866,3271,16689,42599,37268,17755,37777,7541,37045,42907,32159,39593,9064,22845,9954,13906,2510,42587,15548,11702,19565,7043,42596,46053,22642,15388,11967,30326,45598,8102,30445,42553,13682,31954,4945,6515,16809,32642,16078,36150,17684,44117,41928,42499,7573,34788,11111,36819,14792,29034,737,28518,16914,24873,31970,10304,11965,4305,4410,8005,42715,8033,2103,30247,10801,1708,42703,35172,8662,20687,32020,2527,15867,37727,33718,33102,40526,28705,21579,32383,23004,25077,660,11371,9465,35478,42142,7282,14679,36608,5126,26952,45110,31820,38516,28649,39788,30663,29872,17357,363,12823,26520,5067,37531,38453,44725,13870,39796,7467,8783,1814,28530,6745,8288,3514,133,11938,5881,27830,21208,3260,28220,43878,16842,10368,12507,4281,34745,34352,2414,13525,45127,24721,20205,39929,36466,21566,37933,28605,1424,29300,39671,32132,39726,24247,27804,12995,21088,15912,33678,40888,36122,33252,12779,30120,25002,32756,19971,28053,3538,21716,30159,32731,21398,35940,25792,16777,37468,30986,9927,29796,27814,6744,36737,33235,24102,3641,7381,38090,26464,18843,42795,17846,4380,27583,45574,19563,9301,29457,45296,9986,10692,45732,29074,13881,39456,28900,38129,8724,36307,41387,6834,27925,40003,18130,11221,43764,35260,29498,35025,9402,27504,1709,7414,17553,25611,44372,20750,37819,38666,36154,20385,39836,34028,41116,33306,10159,29961,29059,4586,2795,20067,40265,25953,29026,1498,12717,11065,44690,33999,42098,38114,4153,38987,32217,44847,6497,7275,13730,21593,18908,10644,4698,18359,14076,14235,11605,33651,46242,45870,33638,43410,2734,37998,33312,26569,29920,23535,31054,17997,14584,16772,25137,17332,23798,27566,4464,37286,44249,22363,10326,1968,1726,2338,19572,10998,5436,42899,13894,38462,43318,5168,3642,15702,34107,5630,35213,25168,7580,39604,1129,39996,4688,41768,26792,11333,5000,32035,9621,6248,40200,9127,44771,25460,6790,13625,45981,16274,469,4238,25724,17677,25471,22740,35253,37298,10160,42307,8159,5453,28811,29941,28712,6432,24851,30283,23553,24373,7780,19182,43259,17628,41008,13531,5504,2358,35093,8655,43158,34983,8737,19208,43887,9790,33170,40056,34536,44561,26332,34325,8147,10622,24059,43348,134,36508,5331,22100,10787,29663,36164,38237,19654,35186,40144,38457,2632,45146,43017,14331,38765,39446,8332,10772,6125,25363,8021,32973,16890,42484,45681,38217,32511,5086,31160,39872,21452,35190,8736,33579,3672,27676,22043,7797,30925,18176,24018,29564,7213,42354,22394,27930,40366,43591,42966,27113,6051,26256,44796,748,33405,36003,31449,6560,19032,5066,32299,30897,40810,41143,22073,24320,27449,43752,34766,40899,24130,32808,7803,6076,25017,18005,14654,26901,4035,29763,35895,3069,40246,7663,30081,25202,9257,15232,2520,34626,15800,37408,33974,38333,12937,45996,32768,12755,8248,4866,32779,16893,15322,25583,16525,42832,27261,20360,15822,7200,45520,27793,17722,25190,32383,27677,29582,11048,12129,869,35603,36214,18086,27220,46221,9696,20162,5656,34952,37042,8674,23012,33531,21802,26874,12331,17169,3745,45486,42243,26525,1935,33018,1577,38195,14570,31526,38247,20982,6326,25535,16269,24327,43107,20233,41076,8775,11372,28722,45914,9479,17305,18207,19149,28404,38441,3252,33279,18373,30096,30490,35655,45658,41054,7663,21123,37234,32818,5895,7036,9490,20104,9464,35129,20296,10417,22774,42166,29952,19046,21056,30658,31319,10132,1016,19641,3287,21662,33090,17205,40052,24861,21426,32537,127,6082,9378,15647,27427,38112,2860,11255,10207,3314,43687,6068,45839,28135,37792,22681,34519,30590,4507,21788,42228,23390,27343,9649,1548,28586,44899,39899,60,37766,3008,45046,43150,8226,18810,12925,33544,41155,7988,34461,19119,2243,104,41205,26333,21431,14743,8804,7081,17785,2534,24531,29269,34526,24194,87,19020,21167,42780,18438,33179,27629,18556,18447,2083,13024,16077,4368,32106,12335,34270,1437,44615,9494,39096,15707,19135,16684,35136,36431,42172,17430,3559,35268,34236,5244,1397,2211,28269,432,4232,17098,13794,10605,13700,10876,13959,37578,22074,36912,32488,46281,40362,10423,7505,37891,19832,25184,2679,5498,40197,45126,1097,16886,14459,33755,7096,10459,34560,17309,27483,8153,10681,36546,5589,41261,44036,5831,8192,6762,31123,26297,21569,6662,22183,13470,36916,32385,36812,22726,9534,30318,22892,626,40760,35248,30750,31036,6090,41124,29733,37006,11107,35526,9992,45354,24209,36382,7561,12128,39940,1974,29319,12450,30821,11017,3376,572,29900,12457,33604,28055,20132,38394,36214,10010,41819,12961,12228,6191,28112,33267,29359,16550,26024,36737,18641,15032,17088,2679,5332,30891,11513,15099,17977,41312,17992,11826,29932,17208,31380,15147,46109,22987,3177,7914,16526,41865,37710,45796,10571,4244,46273,17823,24120,27424,37041,4435,16597,36154,18946,21805,9204,25582,39902,40159,18193,30797,18574,13394,7710,43603,24305,28893,27538,39139,16068,39580,22220,10917,34098,6712,16106,26748,21778,11485,6030,30187,41767,2965,29472,39655,44410,21500,33369,27481,7400,4836,22613,38254,39717,40447,18794,6617,1772,44635,35021,29344,33073,9675,34053,3638,23589,21831,8732,41697,13681,43647,35440,11830,23125,16844,25172,40365,479,40377,38236,34345,28351,34890,15417,20055,10531,38571,38529,3838,7355,6625,15727,17756,32965,33670,806,21729,30459,14228,33336,26799,41162,29110,19324,23063,7817,18409,40006,23166,27278,9040,15668,43251,31160,36329,35431,45342,29437,37880,41204,18902,25002,15517,20429,15908,16104,39696,19540,40471,32992,43036,31998,34749,10568,6670,27691,19273,34659,45915,34268,29087,8099,34384,32691,22978,29154,24784,42956,12060,20332,9618,677,17402,40095,34111,3802,22173,35421,29409,25616,12073,21504,42800,1985,34774,19034,5710,5589,21477,12228,7729,42746,39389,43373,33913,666,32599,20907,39922,29793,790,17313,30454,2099,29714,9465,42169,37937,39673,15958,29468,18429,34059,31964,12399,44614,29736,32855,15338,31985,7381,27891,18823,7217,19102,34993,38145,33941,36403,45707,2934,2731,10023,42994,37197,25673,5196,19590,20119,38186,10992,43402,43017,165,11521,21864,30607,38394,18433,15468,35440,9377,38849,34505,27184,23068,4658,12613,32028,17084,34608,30590,11045,39693,43402,19997,28212,10183,34323,32755,8862,19537,12427,11555,32929,10440,11118,4816,17349,33842,28537,15314,28032,18747,24651,39492,36758,5385,27720,33109,34024,10050,19678,13980,22455,34509,29579,6324,8421,9450,19478,6134,10522,32408,28651,9639,25594,2229,16201,3735,11769,45388,12186,3710,41500,22749,39191,11054,37587,430,12813,36287,22674,34799,38738,41472,24143,25744,37158,32513,43272,37702,10210,3402,17396,14851,35438,14452,19086,12144,27893,4501,16713,24136,1070,16052,31247,29748,31351,14707,24306,18725,4118,38496,9966,4778,37787,19071,36821,19140,20714,33414,16913,40767,12370,13098,40677,16277,12206,25825,32462,12503,19776,33659,20873,23130,45642,4990,10459,30273,44702,25737,12192,8472,3044,2124,20283,21830,29102,30793,41154,37222,6524,44662,20378,37553,36077,27023,32692,42747,35806,16268,7158,34561,34616,20581,39960,1844,7396,21349,45634,30431,39335,232,24772,2437,42635,31101,37415,37986,15550,5078,40334,21689,12870,1644,20405,21952,34275,22851,28219,44041,35170,5338,15083,34957,28275,41019,10797,14615,41899,5254,42635,7623,1246,14912,8817,4329,1337,23237,32619,20048,24800,35642,46296,26884,12383,9978,1660,44082,8343,27692,12887,4918,16320,17733,23823,7489,33086,40783,44200,13458,18218,19746,8978,19874,24508,28794,16186,37293,20654,1903,19282,17066,21405,5305,31810,31472,23303,44184,36967,15222,40834,3822,12327,2734,3091,12968,28899,44061,20417,12123,8089,27922,35592,9426,3821,31510,6,40844,17545,26765,41299,36795,26976,11401,2558,20274,39661,43809,13428,28548,33556,38266,5498,45298,4150,2764,40011,33698,14242,37260,44460,36038,38845,33591,24934,43059,38216,5792,18178,2615,1200,36136,41273,29094,18606,19386,16886,22638,36047,8971,26097,38702,4051,45148,18711,40091,43478,22754,3350,17422,7866,16787,31045,33421,43622,5564,45334,17891,30559,7016,6381,10703,500,5470,14922,4653,20257,15450,23455,18697,20042,33183,14053,18549,13682,14925,1452,9031,35752,23028,38023,31220,34693,18041,14645,15835,17710,22558,38348,6107,16192,36630,37190,33332,26939,18705,35366,26242,30888,6031,26802,31960,42835,10257,40526,33506,2839,31323,23184,7840,32272,11926,36990,27094,25121,7351,34900,43939,22991,26349,6058,3139,13110,42237,3222,28459,4870,21285,14563,40037,14976,22668,9099,24783,6817,20835,17204,450,35177,39100,43697,16935,22694,29481,1819,23160,42181,10042,20762,37857,19942,16986,7537,40361,30891,770,18628,32776,35829,8450,39092,39548,42597,2507,4618,12633,33657,16700,5133,3121,44766,15420,37126,33080,31277,21262,29298,23359,32238,37703,30378,44467,31528,26606,42452,20011,21405,18045,37864,23493,37933,22112,20670,36117,14851,28385,17929,30550,4587,42673,33621,25781,20403,17313,19017,35223,15595,45621,11162,2255,39662,8429,43371,4235,10387,29180,37133,35970,33845,8519,24756,31203,36867,3473,649,45606,33043,9893,29005,26517,41913,9447,13472,7430,28947,16716,29738,37612,21231,14515,12692,25485,31599,36796,43403,2992,26291,29783,37999,22350,9333,41977,33963,15191,21692,18909,26826,17381,32575,32571,10877,21672,29252,38499,3757,32776,39261,42777,34716,18486,6705,7402,40686,30202,3702,25251,31074,41364,39946,16829,41295,24979,40802,41425,20799,17535,40543,4088,13523,19314,1309,40483,3326,40339,34742,41952,14303,42514,44355,18698,21296,42374,7687,13656,30178,30300,37758,28177,38720,43157,25688,18029,26316,2289,1621,10799,34582,3974,3498,8837,1084,30224,24773,35232,34141,5119,264,39012,29495,41074,27159,10546,7192,3772,16727,12756,27147,27098,33691,41189,38006,11411,15716,30900,22497,25615,1658,20133,46214,22917,45332,32981,25665,16514,21593,6117,17581,5228,29814,36622,16446,12542,34062,5601,9280,21130,844,17563,20798,26963,27442,42641,9506,29055,38971,32926,44171,15465,2330,22813,42823,11782,7556,10578,22625,35414,33375,28905,10409,29624,3948,12115,45387,44407,22040,26168,40141,14837,35941,28960,41669,39066,26665,23618,39035,18847,40837,28139,20827,17801,36975,11804,40214,21909,24889,20564,13503,45178,35643,15963,30637,44819,7619,14740,863,19706,19562,38916,23457,45742,15312,16079,37079,16738,10616,6800,33647,27661,12647,43652,23869,4781,5037,45614,24547,45807,23653,18829,18118,18723,46227,29400,17767,34843,14920,7046,31881,26902,12741,28569,30663,37270,3441,15986,19015,425,30089,16964,815,20875,5586,28109,11476,18163,3027,37436,26165,13652,42925,31018,2603,8203,7763,34573,3630,3573,20954,37588,35812,13784,39305,37292,30522,39407,14850,4785,30436,6758,27711,5535,34642,17166,15449,13553,19332,22352,42426,1976,11041,7648,509,24368,9957,24030,17564,34401,23353,19323,37551,2583,2900,10571,4209,41364,45636,6923,45680,24508,9441,14959,36869,35517,34138,37483,5448,13895,24238,4769,21828,4522,31430,20195,11198,24451,27909,28550,31858,15456,25714,10307,17484,27842,37402,38793,10366,34598,45871,24530,7842,2687,45542,8942,39739,42156,39923,14119,8190,2551,4222,13879,5438,20484,45026,845,11698,25700,1670,24595,42145,17109,11274,18714,17007,5665,32941,7483,30026,37536,4162,42848,8987,6759,11228,23724,9463,9227,28560,42021,12381,42288,9144,40602,46141,28025,21754,13139,29512,37373,24887,12277,23249,32109,33948,20132,6263,4823,22707,37806,3242,20621,19736,14076,31570,7306,28400,31345,41586,22111,25146,11266,407,20177,25508,41599,40489,12139,27082,8659,35260,42091,34451,4564,32269,37491,40308,42074,22913,15089,27954,208,3209,5690,2401,34880,38603,30639,6747,16836,3320,1848,16518,22006,6090,11088,42747,28921,17388,33048,17618,40906,9571,27902,37787,21627,21907,45144,38805,24750,9353,34902,768,28852,35823,10418,36113,22513,10150,8240,25203,6117,26421,28060,8370,15434,33428,37461,26765,1975,15270,22151,42200,44546,29406,30301,44222,2601,40988,19193,23001,32311,12163,30124,43392,21312,4423,6000,16593,21286,43248,26333,41608,44187,37214,33757,16074,1669,4681,44911,30663,40079,29367,42452,10863,14119,12084,40109,28038,25809,41781,27941,46296,34277,25573,33956,32093,17679,30399,13334,35028,42948,18551,23724,12612,6322,3309,17820,42907,25383,18730,4339,23645,44827,11358,22154,17432,39757,32986,33418,12213,26241,40637,41401,42635,8670,32034,7159,29210,44876,41795,35387,7764,2658,38127,11818,41470,27522,5932,9154,37072,41400,28393,11353,8474,45995,29143,12563,34944,19125,23371,14633,16227,20797,26861,33582,33896,39746,255,31930,14198,44068,22787,31407,26502,7035,42429,13529,18452,19615,38622,12575,37117,5959,37163,37417,20874,33289,1801,40454,1304,34945,15414,42631,34670,36042,38422,29208,45337,42586,4716,21676,27278,39912,5395,25960,44916,34047,2352,16229,2055,4759,44130,33490,3085,2785,7683,13217,43508,35996,18450,38962,16801,27774,30464,23065,35818,41587,36596,20509,9377,28955,14857,23685,22577,34951,27763,40138,2581,7601,3967,22478,44146,46043,33252,43001,10285,2275,30153,32793,44476,33146,39552,11259,45651,9598,12496,45762,15838,25229,43225,23246,35620,19913,10151,4607,29746,23936,26142,7864,18042,2633,13159,13375,45307,35983,9785,41866,28224,42670,3229,36119,38395,9541,43596,41624,27585,18017,2815,5858,34464,6397,23770,12667,31586,21036,45534,34131,36116,26683,3534,34700,25724,17183,42875,44275,25039,19494,260,43293,20125,29227,42295,36699,6150,8952,10800,2143,29728,45172,34091,12258,32206,17095,3562,38280,4218,44517,19414,12042,30,20217,4267,9149,36953,17140,26262,13758,32742,44772,32316,8393,22363,35182,15678,24406,31753,17637,24073,15410,31962,9902,43024,40316,27648,44586,1230,21611,32908,18351,19818,40715,35767,15560,20536,19661,19110,9963,26912,25536,3486,40713,3092,12529,46171,821,1859,27931,19289,16442,24821,37186,27398,41844,11535,13960,34572};
    while (scanf("%d",&N)!=EOF) {
            printf("%d\n", res[N]);
        }

    return 0;
}

No te pierdas nada.

Sigue en contacto con Isaac Lozano Osorio!