第一题:

#include<iostream>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
int main()
{set<int>res;for(int i = 1; i <= 1200000; i++){if(1200000%i == 0){res.insert(i);res.insert(1200000/i);}}/*set<int>::iterator it = res.begin();for( ; it != res.end(); it++){cout<<*it<<endl;}*/cout<<res.size();return 0;
}

第二题:

第三题:上一也是这个,上次看成二叉树的了。。

第四题:

#include<iostream>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
int main()
{int res =0;for(int i =1; i<=2019;i++){int t = i;while(t > 0){int tt = t%10;if(tt==9){cout<<i<<endl;res++;break; }t/=10;}}cout<<res;return 0;
}

第五题:我怕时间复杂度有点高,就先打了表(这里网页可能有点卡,哈哈)


打表用的
#include<iostream>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
int main()
{int res =0;int n=0;for(int i = 1; i <= 1000000; i++){int t = i;int t1 = 9;bool flag = true;while(t > 0){//从右往左比int t2 = t%10;if(t1 < t2){flag = false;break;}else{t1 = t2;}t/=10;}if(flag){n++;cout<<i<<","; }}cout<<n; return 0;
}
提交的代码:
#include<iostream>
using namespace std;int main()
{int n;cin>>n;int res = 0;int nums[5100] = {1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,17,18,19,22,23,24,25,26,27,28,29,33,34,35,36,37,38,39,44,45,46,47,48,49,55,56,57,58,59,66,67,68,69,77,78,79,88,89,99,111,112,113,114,115,116,117,118,119,122,123,124,125,126,127,128,129,133,134,135,136,137,138,139,144,145,146,147,148,149,155,156,157,158,159,166,167,168,169,177,178,179,188,189,199,222,223,224,225,226,227,228,229,233,234,235,236,237,238,239,244,245,246,247,248,249,255,256,257,258,259,266,267,268,269,277,278,279,288,289,299,333,334,335,336,337,338,339,344,345,346,347,348,349,355,356,357,358,359,366,367,368,369,377,378,379,388,389,399,444,445,446,447,448,449,455,456,457,458,459,466,467,468,469,477,478,479,488,489,499,555,556,557,558,559,566,567,568,569,577,578,579,588,589,599,666,667,668,669,677,678,679,688,689,699,777,778,779,788,789,799,888,889,899,999,1111,1112,1113,1114,1115,1116,1117,1118,1119,1122,1123,1124,1125,1126,1127,1128,1129,1133,1134,1135,1136,1137,1138,1139,1144,1145,1146,1147,1148,1149,1155,1156,1157,1158,1159,1166,1167,1168,1169,1177,1178,1179,1188,1189,1199,1222,1223,1224,1225,1226,1227,1228,1229,1233,1234,1235,1236,1237,1238,1239,1244,1245,1246,1247,1248,1249,1255,1256,1257,1258,1259,1266,1267,1268,1269,1277,1278,1279,1288,1289,1299,1333,1334,1335,1336,1337,1338,1339,1344,1345,1346,1347,1348,1349,1355,1356,1357,1358,1359,1366,1367,1368,1369,1377,1378,1379,1388,1389,1399,1444,1445,1446,1447,1448,1449,1455,1456,1457,1458,1459,1466,1467,1468,1469,1477,1478,1479,1488,1489,1499,1555,1556,1557,1558,1559,1566,1567,1568,1569,1577,1578,1579,1588,1589,1599,1666,1667,1668,1669,1677,1678,1679,1688,1689,1699,1777,1778,1779,1788,1789,1799,1888,1889,1899,1999,2222,2223,2224,2225,2226,2227,2228,2229,2233,2234,2235,2236,2237,2238,2239,2244,2245,2246,2247,2248,2249,2255,2256,2257,2258,2259,2266,2267,2268,2269,2277,2278,2279,2288,2289,2299,2333,2334,2335,2336,2337,2338,2339,2344,2345,2346,2347,2348,2349,2355,2356,2357,2358,2359,2366,2367,2368,2369,2377,2378,2379,2388,2389,2399,2444,2445,2446,2447,2448,2449,2455,2456,2457,2458,2459,2466,2467,2468,2469,2477,2478,2479,2488,2489,2499,2555,2556,2557,2558,2559,2566,2567,2568,2569,2577,2578,2579,2588,2589,2599,2666,2667,2668,2669,2677,2678,2679,2688,2689,2699,2777,2778,2779,2788,2789,2799,2888,2889,2899,2999,3333,3334,3335,3336,3337,3338,3339,3344,3345,3346,3347,3348,3349,3355,3356,3357,3358,3359,3366,3367,3368,3369,3377,3378,3379,3388,3389,3399,3444,3445,3446,3447,3448,3449,3455,3456,3457,3458,3459,3466,3467,3468,3469,3477,3478,3479,3488,3489,3499,3555,3556,3557,3558,3559,3566,3567,3568,3569,3577,3578,3579,3588,3589,3599,3666,3667,3668,3669,3677,3678,3679,3688,3689,3699,3777,3778,3779,3788,3789,3799,3888,3889,3899,3999,4444,4445,4446,4447,4448,4449,4455,4456,4457,4458,4459,4466,4467,4468,4469,4477,4478,4479,4488,4489,4499,4555,4556,4557,4558,4559,4566,4567,4568,4569,4577,4578,4579,4588,4589,4599,4666,4667,4668,4669,4677,4678,4679,4688,4689,4699,4777,4778,4779,4788,4789,4799,4888,4889,4899,4999,5555,5556,5557,5558,5559,5566,5567,5568,5569,5577,5578,5579,5588,5589,5599,5666,5667,5668,5669,5677,5678,5679,5688,5689,5699,5777,5778,5779,5788,5789,5799,5888,5889,5899,5999,6666,6667,6668,6669,6677,6678,6679,6688,6689,6699,6777,6778,6779,6788,6789,6799,6888,6889,6899,6999,7777,7778,7779,7788,7789,7799,7888,7889,7899,7999,8888,8889,8899,8999,9999,11111,11112,11113,11114,11115,11116,11117,11118,11119,11122,11123,11124,11125,11126,11127,11128,11129,11133,11134,11135,11136,11137,11138,11139,11144,11145,11146,11147,11148,11149,11155,11156,11157,11158,11159,11166,11167,11168,11169,11177,11178,11179,11188,11189,11199,11222,11223,11224,11225,11226,11227,11228,11229,11233,11234,11235,11236,11237,11238,11239,11244,11245,11246,11247,11248,11249,11255,11256,11257,11258,11259,11266,11267,11268,11269,11277,11278,11279,11288,11289,11299,11333,11334,11335,11336,11337,11338,11339,11344,11345,11346,11347,11348,11349,11355,11356,11357,11358,11359,11366,11367,11368,11369,11377,11378,11379,11388,11389,11399,11444,11445,11446,11447,11448,11449,11455,11456,11457,11458,11459,11466,11467,11468,11469,11477,11478,11479,11488,11489,11499,11555,11556,11557,11558,11559,11566,11567,11568,11569,11577,11578,11579,11588,11589,11599,11666,11667,11668,11669,11677,11678,11679,11688,11689,11699,11777,11778,11779,11788,11789,11799,11888,11889,11899,11999,12222,12223,12224,12225,12226,12227,12228,12229,12233,12234,12235,12236,12237,12238,12239,12244,12245,12246,12247,12248,12249,12255,12256,12257,12258,12259,12266,12267,12268,12269,12277,12278,12279,12288,12289,12299,12333,12334,12335,12336,12337,12338,12339,12344,12345,12346,12347,12348,12349,12355,12356,12357,12358,12359,12366,12367,12368,12369,12377,12378,12379,12388,12389,12399,12444,12445,12446,12447,12448,12449,12455,12456,12457,12458,12459,12466,12467,12468,12469,12477,12478,12479,12488,12489,12499,12555,12556,12557,12558,12559,12566,12567,12568,12569,12577,12578,12579,12588,12589,12599,12666,12667,12668,12669,12677,12678,12679,12688,12689,12699,12777,12778,12779,12788,12789,12799,12888,12889,12899,12999,13333,13334,13335,13336,13337,13338,13339,13344,13345,13346,13347,13348,13349,13355,13356,13357,13358,13359,13366,13367,13368,13369,13377,13378,13379,13388,13389,13399,13444,13445,13446,13447,13448,13449,13455,13456,13457,13458,13459,13466,13467,13468,13469,13477,13478,13479,13488,13489,13499,13555,13556,13557,13558,13559,13566,13567,13568,13569,13577,13578,13579,13588,13589,13599,13666,13667,13668,13669,13677,13678,13679,13688,13689,13699,13777,13778,13779,13788,13789,13799,13888,13889,13899,13999,14444,14445,14446,14447,14448,14449,14455,14456,14457,14458,14459,14466,14467,14468,14469,14477,14478,14479,14488,14489,14499,14555,14556,14557,14558,14559,14566,14567,14568,14569,14577,14578,14579,14588,14589,14599,14666,14667,14668,14669,14677,14678,14679,14688,14689,14699,14777,14778,14779,14788,14789,14799,14888,14889,14899,14999,15555,15556,15557,15558,15559,15566,15567,15568,15569,15577,15578,15579,15588,15589,15599,15666,15667,15668,15669,15677,15678,15679,15688,15689,15699,15777,15778,15779,15788,15789,15799,15888,15889,15899,15999,16666,16667,16668,16669,16677,16678,16679,16688,16689,16699,16777,16778,16779,16788,16789,16799,16888,16889,16899,16999,17777,17778,17779,17788,17789,17799,17888,17889,17899,17999,18888,18889,18899,18999,19999,22222,22223,22224,22225,22226,22227,22228,22229,22233,22234,22235,22236,22237,22238,22239,22244,22245,22246,22247,22248,22249,22255,22256,22257,22258,22259,22266,22267,22268,22269,22277,22278,22279,22288,22289,22299,22333,22334,22335,22336,22337,22338,22339,22344,22345,22346,22347,22348,22349,22355,22356,22357,22358,22359,22366,22367,22368,22369,22377,22378,22379,22388,22389,22399,22444,22445,22446,22447,22448,22449,22455,22456,22457,22458,22459,22466,22467,22468,22469,22477,22478,22479,22488,22489,22499,22555,22556,22557,22558,22559,22566,22567,22568,22569,22577,22578,22579,22588,22589,22599,22666,22667,22668,22669,22677,22678,22679,22688,22689,22699,22777,22778,22779,22788,22789,22799,22888,22889,22899,22999,23333,23334,23335,23336,23337,23338,23339,23344,23345,23346,23347,23348,23349,23355,23356,23357,23358,23359,23366,23367,23368,23369,23377,23378,23379,23388,23389,23399,23444,23445,23446,23447,23448,23449,23455,23456,23457,23458,23459,23466,23467,23468,23469,23477,23478,23479,23488,23489,23499,23555,23556,23557,23558,23559,23566,23567,23568,23569,23577,23578,23579,23588,23589,23599,23666,23667,23668,23669,23677,23678,23679,23688,23689,23699,23777,23778,23779,23788,23789,23799,23888,23889,23899,23999,24444,24445,24446,24447,24448,24449,24455,24456,24457,24458,24459,24466,24467,24468,24469,24477,24478,24479,24488,24489,24499,24555,24556,24557,24558,24559,24566,24567,24568,24569,24577,24578,24579,24588,24589,24599,24666,24667,24668,24669,24677,24678,24679,24688,24689,24699,24777,24778,24779,24788,24789,24799,24888,24889,24899,24999,25555,25556,25557,25558,25559,25566,25567,25568,25569,25577,25578,25579,25588,25589,25599,25666,25667,25668,25669,25677,25678,25679,25688,25689,25699,25777,25778,25779,25788,25789,25799,25888,25889,25899,25999,26666,26667,26668,26669,26677,26678,26679,26688,26689,26699,26777,26778,26779,26788,26789,26799,26888,26889,26899,26999,27777,27778,27779,27788,27789,27799,27888,27889,27899,27999,28888,28889,28899,28999,29999,33333,33334,33335,33336,33337,33338,33339,33344,33345,33346,33347,33348,33349,33355,33356,33357,33358,33359,33366,33367,33368,33369,33377,33378,33379,33388,33389,33399,33444,33445,33446,33447,33448,33449,33455,33456,33457,33458,33459,33466,33467,33468,33469,33477,33478,33479,33488,33489,33499,33555,33556,33557,33558,33559,33566,33567,33568,33569,33577,33578,33579,33588,33589,33599,33666,33667,33668,33669,33677,33678,33679,33688,33689,33699,33777,33778,33779,33788,33789,33799,33888,33889,33899,33999,34444,34445,34446,34447,34448,34449,34455,34456,34457,34458,34459,34466,34467,34468,34469,34477,34478,34479,34488,34489,34499,34555,34556,34557,34558,34559,34566,34567,34568,34569,34577,34578,34579,34588,34589,34599,34666,34667,34668,34669,34677,34678,34679,34688,34689,34699,34777,34778,34779,34788,34789,34799,34888,34889,34899,34999,35555,35556,35557,35558,35559,35566,35567,35568,35569,35577,35578,35579,35588,35589,35599,35666,35667,35668,35669,35677,35678,35679,35688,35689,35699,35777,35778,35779,35788,35789,35799,35888,35889,35899,35999,36666,36667,36668,36669,36677,36678,36679,36688,36689,36699,36777,36778,36779,36788,36789,36799,36888,36889,36899,36999,37777,37778,37779,37788,37789,37799,37888,37889,37899,37999,38888,38889,38899,38999,39999,44444,44445,44446,44447,44448,44449,44455,44456,44457,44458,44459,44466,44467,44468,44469,44477,44478,44479,44488,44489,44499,44555,44556,44557,44558,44559,44566,44567,44568,44569,44577,44578,44579,44588,44589,44599,44666,44667,44668,44669,44677,44678,44679,44688,44689,44699,44777,44778,44779,44788,44789,44799,44888,44889,44899,44999,45555,45556,45557,45558,45559,45566,45567,45568,45569,45577,45578,45579,45588,45589,45599,45666,45667,45668,45669,45677,45678,45679,45688,45689,45699,45777,45778,45779,45788,45789,45799,45888,45889,45899,45999,46666,46667,46668,46669,46677,46678,46679,46688,46689,46699,46777,46778,46779,46788,46789,46799,46888,46889,46899,46999,47777,47778,47779,47788,47789,47799,47888,47889,47899,47999,48888,48889,48899,48999,49999,55555,55556,55557,55558,55559,55566,55567,55568,55569,55577,55578,55579,55588,55589,55599,55666,55667,55668,55669,55677,55678,55679,55688,55689,55699,55777,55778,55779,55788,55789,55799,55888,55889,55899,55999,56666,56667,56668,56669,56677,56678,56679,56688,56689,56699,56777,56778,56779,56788,56789,56799,56888,56889,56899,56999,57777,57778,57779,57788,57789,57799,57888,57889,57899,57999,58888,58889,58899,58999,59999,66666,66667,66668,66669,66677,66678,66679,66688,66689,66699,66777,66778,66779,66788,66789,66799,66888,66889,66899,66999,67777,67778,67779,67788,67789,67799,67888,67889,67899,67999,68888,68889,68899,68999,69999,77777,77778,77779,77788,77789,77799,77888,77889,77899,77999,78888,78889,78899,78999,79999,88888,88889,88899,88999,89999,99999,111111,111112,111113,111114,111115,111116,111117,111118,111119,111122,111123,111124,111125,111126,111127,111128,111129,111133,111134,111135,111136,111137,111138,111139,111144,111145,111146,111147,111148,111149,111155,111156,111157,111158,111159,111166,111167,111168,111169,111177,111178,111179,111188,111189,111199,111222,111223,111224,111225,111226,111227,111228,111229,111233,111234,111235,111236,111237,111238,111239,111244,111245,111246,111247,111248,111249,111255,111256,111257,111258,111259,111266,111267,111268,111269,111277,111278,111279,111288,111289,111299,111333,111334,111335,111336,111337,111338,111339,111344,111345,111346,111347,111348,111349,111355,111356,111357,111358,111359,111366,111367,111368,111369,111377,111378,111379,111388,111389,111399,111444,111445,111446,111447,111448,111449,111455,111456,111457,111458,111459,111466,111467,111468,111469,111477,111478,111479,111488,111489,111499,111555,111556,111557,111558,111559,111566,111567,111568,111569,111577,111578,111579,111588,111589,111599,111666,111667,111668,111669,111677,111678,111679,111688,111689,111699,111777,111778,111779,111788,111789,111799,111888,111889,111899,111999,112222,112223,112224,112225,112226,112227,112228,112229,112233,112234,112235,112236,112237,112238,112239,112244,112245,112246,112247,112248,112249,112255,112256,112257,112258,112259,112266,112267,112268,112269,112277,112278,112279,112288,112289,112299,112333,112334,112335,112336,112337,112338,112339,112344,112345,112346,112347,112348,112349,112355,112356,112357,112358,112359,112366,112367,112368,112369,112377,112378,112379,112388,112389,112399,112444,112445,112446,112447,112448,112449,112455,112456,112457,112458,112459,112466,112467,112468,112469,112477,112478,112479,112488,112489,112499,112555,112556,112557,112558,112559,112566,112567,112568,112569,112577,112578,112579,112588,112589,112599,112666,112667,112668,112669,112677,112678,112679,112688,112689,112699,112777,112778,112779,112788,112789,112799,112888,112889,112899,112999,113333,113334,113335,113336,113337,113338,113339,113344,113345,113346,113347,113348,113349,113355,113356,113357,113358,113359,113366,113367,113368,113369,113377,113378,113379,113388,113389,113399,113444,113445,113446,113447,113448,113449,113455,113456,113457,113458,113459,113466,113467,113468,113469,113477,113478,113479,113488,113489,113499,113555,113556,113557,113558,113559,113566,113567,113568,113569,113577,113578,113579,113588,113589,113599,113666,113667,113668,113669,113677,113678,113679,113688,113689,113699,113777,113778,113779,113788,113789,113799,113888,113889,113899,113999,114444,114445,114446,114447,114448,114449,114455,114456,114457,114458,114459,114466,114467,114468,114469,114477,114478,114479,114488,114489,114499,114555,114556,114557,114558,114559,114566,114567,114568,114569,114577,114578,114579,114588,114589,114599,114666,114667,114668,114669,114677,114678,114679,114688,114689,114699,114777,114778,114779,114788,114789,114799,114888,114889,114899,114999,115555,115556,115557,115558,115559,115566,115567,115568,115569,115577,115578,115579,115588,115589,115599,115666,115667,115668,115669,115677,115678,115679,115688,115689,115699,115777,115778,115779,115788,115789,115799,115888,115889,115899,115999,116666,116667,116668,116669,116677,116678,116679,116688,116689,116699,116777,116778,116779,116788,116789,116799,116888,116889,116899,116999,117777,117778,117779,117788,117789,117799,117888,117889,117899,117999,118888,118889,118899,118999,119999,122222,122223,122224,122225,122226,122227,122228,122229,122233,122234,122235,122236,122237,122238,122239,122244,122245,122246,122247,122248,122249,122255,122256,122257,122258,122259,122266,122267,122268,122269,122277,122278,122279,122288,122289,122299,122333,122334,122335,122336,122337,122338,122339,122344,122345,122346,122347,122348,122349,122355,122356,122357,122358,122359,122366,122367,122368,122369,122377,122378,122379,122388,122389,122399,122444,122445,122446,122447,122448,122449,122455,122456,122457,122458,122459,122466,122467,122468,122469,122477,122478,122479,122488,122489,122499,122555,122556,122557,122558,122559,122566,122567,122568,122569,122577,122578,122579,122588,122589,122599,122666,122667,122668,122669,122677,122678,122679,122688,122689,122699,122777,122778,122779,122788,122789,122799,122888,122889,122899,122999,123333,123334,123335,123336,123337,123338,123339,123344,123345,123346,123347,123348,123349,123355,123356,123357,123358,123359,123366,123367,123368,123369,123377,123378,123379,123388,123389,123399,123444,123445,123446,123447,123448,123449,123455,123456,123457,123458,123459,123466,123467,123468,123469,123477,123478,123479,123488,123489,123499,123555,123556,123557,123558,123559,123566,123567,123568,123569,123577,123578,123579,123588,123589,123599,123666,123667,123668,123669,123677,123678,123679,123688,123689,123699,123777,123778,123779,123788,123789,123799,123888,123889,123899,123999,124444,124445,124446,124447,124448,124449,124455,124456,124457,124458,124459,124466,124467,124468,124469,124477,124478,124479,124488,124489,124499,124555,124556,124557,124558,124559,124566,124567,124568,124569,124577,124578,124579,124588,124589,124599,124666,124667,124668,124669,124677,124678,124679,124688,124689,124699,124777,124778,124779,124788,124789,124799,124888,124889,124899,124999,125555,125556,125557,125558,125559,125566,125567,125568,125569,125577,125578,125579,125588,125589,125599,125666,125667,125668,125669,125677,125678,125679,125688,125689,125699,125777,125778,125779,125788,125789,125799,125888,125889,125899,125999,126666,126667,126668,126669,126677,126678,126679,126688,126689,126699,126777,126778,126779,126788,126789,126799,126888,126889,126899,126999,127777,127778,127779,127788,127789,127799,127888,127889,127899,127999,128888,128889,128899,128999,129999,133333,133334,133335,133336,133337,133338,133339,133344,133345,133346,133347,133348,133349,133355,133356,133357,133358,133359,133366,133367,133368,133369,133377,133378,133379,133388,133389,133399,133444,133445,133446,133447,133448,133449,133455,133456,133457,133458,133459,133466,133467,133468,133469,133477,133478,133479,133488,133489,133499,133555,133556,133557,133558,133559,133566,133567,133568,133569,133577,133578,133579,133588,133589,133599,133666,133667,133668,133669,133677,133678,133679,133688,133689,133699,133777,133778,133779,133788,133789,133799,133888,133889,133899,133999,134444,134445,134446,134447,134448,134449,134455,134456,134457,134458,134459,134466,134467,134468,134469,134477,134478,134479,134488,134489,134499,134555,134556,134557,134558,134559,134566,134567,134568,134569,134577,134578,134579,134588,134589,134599,134666,134667,134668,134669,134677,134678,134679,134688,134689,134699,134777,134778,134779,134788,134789,134799,134888,134889,134899,134999,135555,135556,135557,135558,135559,135566,135567,135568,135569,135577,135578,135579,135588,135589,135599,135666,135667,135668,135669,135677,135678,135679,135688,135689,135699,135777,135778,135779,135788,135789,135799,135888,135889,135899,135999,136666,136667,136668,136669,136677,136678,136679,136688,136689,136699,136777,136778,136779,136788,136789,136799,136888,136889,136899,136999,137777,137778,137779,137788,137789,137799,137888,137889,137899,137999,138888,138889,138899,138999,139999,144444,144445,144446,144447,144448,144449,144455,144456,144457,144458,144459,144466,144467,144468,144469,144477,144478,144479,144488,144489,144499,144555,144556,144557,144558,144559,144566,144567,144568,144569,144577,144578,144579,144588,144589,144599,144666,144667,144668,144669,144677,144678,144679,144688,144689,144699,144777,144778,144779,144788,144789,144799,144888,144889,144899,144999,145555,145556,145557,145558,145559,145566,145567,145568,145569,145577,145578,145579,145588,145589,145599,145666,145667,145668,145669,145677,145678,145679,145688,145689,145699,145777,145778,145779,145788,145789,145799,145888,145889,145899,145999,146666,146667,146668,146669,146677,146678,146679,146688,146689,146699,146777,146778,146779,146788,146789,146799,146888,146889,146899,146999,147777,147778,147779,147788,147789,147799,147888,147889,147899,147999,148888,148889,148899,148999,149999,155555,155556,155557,155558,155559,155566,155567,155568,155569,155577,155578,155579,155588,155589,155599,155666,155667,155668,155669,155677,155678,155679,155688,155689,155699,155777,155778,155779,155788,155789,155799,155888,155889,155899,155999,156666,156667,156668,156669,156677,156678,156679,156688,156689,156699,156777,156778,156779,156788,156789,156799,156888,156889,156899,156999,157777,157778,157779,157788,157789,157799,157888,157889,157899,157999,158888,158889,158899,158999,159999,166666,166667,166668,166669,166677,166678,166679,166688,166689,166699,166777,166778,166779,166788,166789,166799,166888,166889,166899,166999,167777,167778,167779,167788,167789,167799,167888,167889,167899,167999,168888,168889,168899,168999,169999,177777,177778,177779,177788,177789,177799,177888,177889,177899,177999,178888,178889,178899,178999,179999,188888,188889,188899,188999,189999,199999,222222,222223,222224,222225,222226,222227,222228,222229,222233,222234,222235,222236,222237,222238,222239,222244,222245,222246,222247,222248,222249,222255,222256,222257,222258,222259,222266,222267,222268,222269,222277,222278,222279,222288,222289,222299,222333,222334,222335,222336,222337,222338,222339,222344,222345,222346,222347,222348,222349,222355,222356,222357,222358,222359,222366,222367,222368,222369,222377,222378,222379,222388,222389,222399,222444,222445,222446,222447,222448,222449,222455,222456,222457,222458,222459,222466,222467,222468,222469,222477,222478,222479,222488,222489,222499,222555,222556,222557,222558,222559,222566,222567,222568,222569,222577,222578,222579,222588,222589,222599,222666,222667,222668,222669,222677,222678,222679,222688,222689,222699,222777,222778,222779,222788,222789,222799,222888,222889,222899,222999,223333,223334,223335,223336,223337,223338,223339,223344,223345,223346,223347,223348,223349,223355,223356,223357,223358,223359,223366,223367,223368,223369,223377,223378,223379,223388,223389,223399,223444,223445,223446,223447,223448,223449,223455,223456,223457,223458,223459,223466,223467,223468,223469,223477,223478,223479,223488,223489,223499,223555,223556,223557,223558,223559,223566,223567,223568,223569,223577,223578,223579,223588,223589,223599,223666,223667,223668,223669,223677,223678,223679,223688,223689,223699,223777,223778,223779,223788,223789,223799,223888,223889,223899,223999,224444,224445,224446,224447,224448,224449,224455,224456,224457,224458,224459,224466,224467,224468,224469,224477,224478,224479,224488,224489,224499,224555,224556,224557,224558,224559,224566,224567,224568,224569,224577,224578,224579,224588,224589,224599,224666,224667,224668,224669,224677,224678,224679,224688,224689,224699,224777,224778,224779,224788,224789,224799,224888,224889,224899,224999,225555,225556,225557,225558,225559,225566,225567,225568,225569,225577,225578,225579,225588,225589,225599,225666,225667,225668,225669,225677,225678,225679,225688,225689,225699,225777,225778,225779,225788,225789,225799,225888,225889,225899,225999,226666,226667,226668,226669,226677,226678,226679,226688,226689,226699,226777,226778,226779,226788,226789,226799,226888,226889,226899,226999,227777,227778,227779,227788,227789,227799,227888,227889,227899,227999,228888,228889,228899,228999,229999,233333,233334,233335,233336,233337,233338,233339,233344,233345,233346,233347,233348,233349,233355,233356,233357,233358,233359,233366,233367,233368,233369,233377,233378,233379,233388,233389,233399,233444,233445,233446,233447,233448,233449,233455,233456,233457,233458,233459,233466,233467,233468,233469,233477,233478,233479,233488,233489,233499,233555,233556,233557,233558,233559,233566,233567,233568,233569,233577,233578,233579,233588,233589,233599,233666,233667,233668,233669,233677,233678,233679,233688,233689,233699,233777,233778,233779,233788,233789,233799,233888,233889,233899,233999,234444,234445,234446,234447,234448,234449,234455,234456,234457,234458,234459,234466,234467,234468,234469,234477,234478,234479,234488,234489,234499,234555,234556,234557,234558,234559,234566,234567,234568,234569,234577,234578,234579,234588,234589,234599,234666,234667,234668,234669,234677,234678,234679,234688,234689,234699,234777,234778,234779,234788,234789,234799,234888,234889,234899,234999,235555,235556,235557,235558,235559,235566,235567,235568,235569,235577,235578,235579,235588,235589,235599,235666,235667,235668,235669,235677,235678,235679,235688,235689,235699,235777,235778,235779,235788,235789,235799,235888,235889,235899,235999,236666,236667,236668,236669,236677,236678,236679,236688,236689,236699,236777,236778,236779,236788,236789,236799,236888,236889,236899,236999,237777,237778,237779,237788,237789,237799,237888,237889,237899,237999,238888,238889,238899,238999,239999,244444,244445,244446,244447,244448,244449,244455,244456,244457,244458,244459,244466,244467,244468,244469,244477,244478,244479,244488,244489,244499,244555,244556,244557,244558,244559,244566,244567,244568,244569,244577,244578,244579,244588,244589,244599,244666,244667,244668,244669,244677,244678,244679,244688,244689,244699,244777,244778,244779,244788,244789,244799,244888,244889,244899,244999,245555,245556,245557,245558,245559,245566,245567,245568,245569,245577,245578,245579,245588,245589,245599,245666,245667,245668,245669,245677,245678,245679,245688,245689,245699,245777,245778,245779,245788,245789,245799,245888,245889,245899,245999,246666,246667,246668,246669,246677,246678,246679,246688,246689,246699,246777,246778,246779,246788,246789,246799,246888,246889,246899,246999,247777,247778,247779,247788,247789,247799,247888,247889,247899,247999,248888,248889,248899,248999,249999,255555,255556,255557,255558,255559,255566,255567,255568,255569,255577,255578,255579,255588,255589,255599,255666,255667,255668,255669,255677,255678,255679,255688,255689,255699,255777,255778,255779,255788,255789,255799,255888,255889,255899,255999,256666,256667,256668,256669,256677,256678,256679,256688,256689,256699,256777,256778,256779,256788,256789,256799,256888,256889,256899,256999,257777,257778,257779,257788,257789,257799,257888,257889,257899,257999,258888,258889,258899,258999,259999,266666,266667,266668,266669,266677,266678,266679,266688,266689,266699,266777,266778,266779,266788,266789,266799,266888,266889,266899,266999,267777,267778,267779,267788,267789,267799,267888,267889,267899,267999,268888,268889,268899,268999,269999,277777,277778,277779,277788,277789,277799,277888,277889,277899,277999,278888,278889,278899,278999,279999,288888,288889,288899,288999,289999,299999,333333,333334,333335,333336,333337,333338,333339,333344,333345,333346,333347,333348,333349,333355,333356,333357,333358,333359,333366,333367,333368,333369,333377,333378,333379,333388,333389,333399,333444,333445,333446,333447,333448,333449,333455,333456,333457,333458,333459,333466,333467,333468,333469,333477,333478,333479,333488,333489,333499,333555,333556,333557,333558,333559,333566,333567,333568,333569,333577,333578,333579,333588,333589,333599,333666,333667,333668,333669,333677,333678,333679,333688,333689,333699,333777,333778,333779,333788,333789,333799,333888,333889,333899,333999,334444,334445,334446,334447,334448,334449,334455,334456,334457,334458,334459,334466,334467,334468,334469,334477,334478,334479,334488,334489,334499,334555,334556,334557,334558,334559,334566,334567,334568,334569,334577,334578,334579,334588,334589,334599,334666,334667,334668,334669,334677,334678,334679,334688,334689,334699,334777,334778,334779,334788,334789,334799,334888,334889,334899,334999,335555,335556,335557,335558,335559,335566,335567,335568,335569,335577,335578,335579,335588,335589,335599,335666,335667,335668,335669,335677,335678,335679,335688,335689,335699,335777,335778,335779,335788,335789,335799,335888,335889,335899,335999,336666,336667,336668,336669,336677,336678,336679,336688,336689,336699,336777,336778,336779,336788,336789,336799,336888,336889,336899,336999,337777,337778,337779,337788,337789,337799,337888,337889,337899,337999,338888,338889,338899,338999,339999,344444,344445,344446,344447,344448,344449,344455,344456,344457,344458,344459,344466,344467,344468,344469,344477,344478,344479,344488,344489,344499,344555,344556,344557,344558,344559,344566,344567,344568,344569,344577,344578,344579,344588,344589,344599,344666,344667,344668,344669,344677,344678,344679,344688,344689,344699,344777,344778,344779,344788,344789,344799,344888,344889,344899,344999,345555,345556,345557,345558,345559,345566,345567,345568,345569,345577,345578,345579,345588,345589,345599,345666,345667,345668,345669,345677,345678,345679,345688,345689,345699,345777,345778,345779,345788,345789,345799,345888,345889,345899,345999,346666,346667,346668,346669,346677,346678,346679,346688,346689,346699,346777,346778,346779,346788,346789,346799,346888,346889,346899,346999,347777,347778,347779,347788,347789,347799,347888,347889,347899,347999,348888,348889,348899,348999,349999,355555,355556,355557,355558,355559,355566,355567,355568,355569,355577,355578,355579,355588,355589,355599,355666,355667,355668,355669,355677,355678,355679,355688,355689,355699,355777,355778,355779,355788,355789,355799,355888,355889,355899,355999,356666,356667,356668,356669,356677,356678,356679,356688,356689,356699,356777,356778,356779,356788,356789,356799,356888,356889,356899,356999,357777,357778,357779,357788,357789,357799,357888,357889,357899,357999,358888,358889,358899,358999,359999,366666,366667,366668,366669,366677,366678,366679,366688,366689,366699,366777,366778,366779,366788,366789,366799,366888,366889,366899,366999,367777,367778,367779,367788,367789,367799,367888,367889,367899,367999,368888,368889,368899,368999,369999,377777,377778,377779,377788,377789,377799,377888,377889,377899,377999,378888,378889,378899,378999,379999,388888,388889,388899,388999,389999,399999,444444,444445,444446,444447,444448,444449,444455,444456,444457,444458,444459,444466,444467,444468,444469,444477,444478,444479,444488,444489,444499,444555,444556,444557,444558,444559,444566,444567,444568,444569,444577,444578,444579,444588,444589,444599,444666,444667,444668,444669,444677,444678,444679,444688,444689,444699,444777,444778,444779,444788,444789,444799,444888,444889,444899,444999,445555,445556,445557,445558,445559,445566,445567,445568,445569,445577,445578,445579,445588,445589,445599,445666,445667,445668,445669,445677,445678,445679,445688,445689,445699,445777,445778,445779,445788,445789,445799,445888,445889,445899,445999,446666,446667,446668,446669,446677,446678,446679,446688,446689,446699,446777,446778,446779,446788,446789,446799,446888,446889,446899,446999,447777,447778,447779,447788,447789,447799,447888,447889,447899,447999,448888,448889,448899,448999,449999,455555,455556,455557,455558,455559,455566,455567,455568,455569,455577,455578,455579,455588,455589,455599,455666,455667,455668,455669,455677,455678,455679,455688,455689,455699,455777,455778,455779,455788,455789,455799,455888,455889,455899,455999,456666,456667,456668,456669,456677,456678,456679,456688,456689,456699,456777,456778,456779,456788,456789,456799,456888,456889,456899,456999,457777,457778,457779,457788,457789,457799,457888,457889,457899,457999,458888,458889,458899,458999,459999,466666,466667,466668,466669,466677,466678,466679,466688,466689,466699,466777,466778,466779,466788,466789,466799,466888,466889,466899,466999,467777,467778,467779,467788,467789,467799,467888,467889,467899,467999,468888,468889,468899,468999,469999,477777,477778,477779,477788,477789,477799,477888,477889,477899,477999,478888,478889,478899,478999,479999,488888,488889,488899,488999,489999,499999,555555,555556,555557,555558,555559,555566,555567,555568,555569,555577,555578,555579,555588,555589,555599,555666,555667,555668,555669,555677,555678,555679,555688,555689,555699,555777,555778,555779,555788,555789,555799,555888,555889,555899,555999,556666,556667,556668,556669,556677,556678,556679,556688,556689,556699,556777,556778,556779,556788,556789,556799,556888,556889,556899,556999,557777,557778,557779,557788,557789,557799,557888,557889,557899,557999,558888,558889,558899,558999,559999,566666,566667,566668,566669,566677,566678,566679,566688,566689,566699,566777,566778,566779,566788,566789,566799,566888,566889,566899,566999,567777,567778,567779,567788,567789,567799,567888,567889,567899,567999,568888,568889,568899,568999,569999,577777,577778,577779,577788,577789,577799,577888,577889,577899,577999,578888,578889,578899,578999,579999,588888,588889,588899,588999,589999,599999,666666,666667,666668,666669,666677,666678,666679,666688,666689,666699,666777,666778,666779,666788,666789,666799,666888,666889,666899,666999,667777,667778,667779,667788,667789,667799,667888,667889,667899,667999,668888,668889,668899,668999,669999,677777,677778,677779,677788,677789,677799,677888,677889,677899,677999,678888,678889,678899,678999,679999,688888,688889,688899,688999,689999,699999,777777,777778,777779,777788,777789,777799,777888,777889,777899,777999,778888,778889,778899,778999,779999,788888,788889,788899,788999,789999,799999,888888,888889,888899,888999,889999,899999,999999};for(int i =0; i < 5004; i++){if(nums[i] <= n){res++;}}cout<<res;return 0;
}

------更新3月25日 -------------------------------------------------------

不打表也不会超时 时间复杂度最差是O(8*100000)

第六题:


思路:O(n)解法

vector<int>mins(n+1); /// mins[i] 表示 [0,i-1]里最小的元素
vector<int>maxs(n+1); ///maxs[i] 表示[i+1,n-1]里最大的元素
如果`mins[i] < nums[i] && nums[i] < maxs[i]` 答案就加1
#include<iostream>
#include<vector>
using namespace std;int main()
{int n;cin>>n;vector<int>nums(n, 0);vector<int>mins(n+1); /// mins[i] 表示 [0,i-1]里最小的元素vector<int>maxs(n+1); ///maxs[i] 表示[i+1,n-1]里最大的元素mins[0] = 999999999;for(int i = 0; i < n; i++){cin>>nums[i];if(nums[i] < mins[i]){mins[i+1] = nums[i];}else{mins[i+1] = mins[i];}}maxs[n-1] = -999999999;for(int i = n-1; i >= 1; i--){if(nums[i] > maxs[i]){maxs[i-1] = nums[i];}else{maxs[i-1] = maxs[i];}}int res = 0;for(int i = 1; i < n -1; i++){if(mins[i] < nums[i] && nums[i] < maxs[i]){res++;}}cout<<res;return 0;
}

第七题:


#include<iostream>
#include<string>
#include<vector>
using namespace std;int main()
{string str;cin>>str;int n = str.size();vector<bool>dp(n,false);for(int i = 0; i < n; i++){dp[i] = (str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u');} bool flag = true;int cnt = 0;if(dp[0] == true || dp[n-1] == false) flag = false; // 头尾先判断下if(flag == true){int left = 1, right = n-2;while(left < right && dp[left] == false) left++; //跳到第二段while(left < right && dp[right] == true) right--;//跳到第三段if(left < right){//第三段和第二段不是一段for(int i = left; i <= right; i++){//这之间只能有一段是元音连着的 hhheelleellee不行if(dp[i] == true){while(i <= right && dp[i] == true) i++;cnt++;} }} }if(cnt == 1) cout<<"yes";else cout<<"no";return 0;
}

第8题:


一块草地只会扩张一次

#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<set>
using namespace std;int main()
{int n,m;cin>>n>>m;vector< vector<bool> >mp(n, vector<bool>(m, false)); //mp[i][j] = true 则有草queue< pair<int,int> >q;  //队列for(int i = 0; i < n; i++){string str;cin>>str;for(int j = 0; j < m; j++){if(str[j] == 'g'){mp[i][j] = true;pair<int,int>p;p.first = i;p.second = j;q.push(p);}}}int dx[4] = {-1,0,1,0}; //上右下左int dy[4] = {0, 1,0,-1}; //上右下左int k;cin>>k;while(!q.empty() && k > 0){k--;int len = q.size();//当前草地数for(int i = 0; i < len; i++){//扩张pair<int,int>cur = q.front(); q.pop();for(int j = 0; j < 4; j++){int x = cur.first + dx[j], y = cur.second + dy[j];if(x >= 0 && x < n && y >= 0 && y < m && mp[x][y] == false){mp[x][y] = true;pair<int,int>p;p.first = x;p.second = y;q.push(p);}}}}//输出for(int i = 0; i < n; i ++){for(int j = 0; j < m; j++){if(mp[i][j] == true){cout<<"g"; }else{cout<<".";}}cout<<endl;} return 0;
}

第九题:



dfs+记忆化:不能全对,1000的时候好久才有输出

#include<iostream>
#include<vector>
#include<map>
#include<cmath>
#include<set>using namespace std;map<pair<int,int>,int >hash;int dfs(int last1, int last2)
{int lastAbs = abs(last2 - last1);pair<int,int>cur;cur.first = last1;cur.second = lastAbs;if(hash.find(cur) != hash.end()){return hash[cur];}int cnt = 1;for(int i = 1; i < lastAbs; i++){cnt += dfs(i, last1);}cnt %= 10000; hash[cur] = cnt;return cnt;
}
int main()
{int n;cin>>n;int res = 0;for(int i = 1; i <= n; i++){res += dfs(i, n);res %= 10000;}cout<<res;return 0;
}
这题全对的做法参考这篇文章https://blog.csdn.net/zhengwei223/article/details/105065435
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
#include<set>using namespace std;int dp[1010][1010] = {0};
int MOD = 10000;
int dfs(int pre, int cur)
{if(cur < 1) return 0;if(dp[pre][cur] != 0) return dp[pre][cur];return dp[pre][cur] = (1 + dfs(pre, cur-1) + dfs(cur, abs(pre - cur)-1))%MOD;
}
int main()
{int n;cin>>n;int res = 0;res = dfs(n,n)%MOD;cout<<res;return 0;
}

第十题:



一开始写的这个
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>using namespace std;
int main()
{int n,m;cin>>n>>m;priority_queue<pair<int,int>, vector<pair<int,int> >, less<pair<int,int> > >pq;//大根堆vector<pair<int,int> >res;int start = n - m;int num = 0;for(int i = 0; i < n; i++){cin>>num;pair<int,int>p;p.first = num;p.second = i;pq.push(p);if(i >= start){//从第i个数起就得挑最好看的j节目了pair<int,int> t = pq.top();pq.pop();pair<int,int>tmp;tmp.first = t.second;tmp.second = t.first;res.push_back(tmp);}} sort(res.begin(), res.end());for(int i = 0; i < m; i++){cout<<res[i].second<<" ";}return 0;
}
提交的是这个:我好像多想了,应该是上面这
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm> using namespace std;
struct st{int x;int i;st(int _x, int _i){x = _x;i = _i;}friend bool operator <(st a, st b){return a.x != b.x ? a.x < b.x : a.i > b.i; }
};
int main()
{int n,m;cin>>n>>m;priority_queue<st>pq;vector<pair<int,int> >res;int start = n - m;int num = 0;for(int i = 0; i < n; i++){cin>>num;st s(num,i);pq.push(s);if(i >= start){st t = pq.top();pq.pop();pair<int,int>tmp;tmp.first = t.i;tmp.second = t.x;res.push_back(tmp);}} sort(res.begin(), res.end());for(int i = 0; i < m; i++){cout<<res[i].second<<" ";}return 0;
}

应该是聪明反被聪明误了,以下是两者区别(排序不一样)

10 3
1 5 2 5 6 7 5 5 2 2 2

第一个的输出:

第二个的输出:


------3月25日更新:第10题写错了,题意理解错了-------

可以看这个篇,官方老师写的:
https://blog.csdn.net/zhengwei223/article/details/105065435

2020年3月蓝桥杯校内模拟赛题解相关推荐

  1. 蓝桥杯校内模拟赛_C++组

    蓝桥杯校内模拟赛 填空题 填空题比较简单,只需要在空格中填写整数答案即可: 在计算机存储中,15.125GB是多少MB? 解题思路: 1GB=1024MB,打开系统计算器计算即可 答案: 15488 ...

  2. 第十四届蓝桥杯校内模拟赛第一期——Python

    第十四届蓝桥杯校内模拟赛第一期--Python 文章目录 第十四届蓝桥杯校内模拟赛第一期--Python 1.二进制位数 问题描述 参考答案 扩展 2. 晨跑 问题描述 参考答案 扩展 3. 调和级数 ...

  3. 第十四届蓝桥杯校内模拟赛第二期-Java个人题解(仅供参考)

    刚刚结束第十四届蓝桥杯校内模拟赛第二期,在这记录下自己的代码 不保证正确! 不保证正确! 不保证正确! 有问题一起改正!! 题解 2048 代码: package _14届模拟2;public cla ...

  4. 第十四届蓝桥杯校内模拟赛(第三期)Java组题解分享

    文章目录 填空题 最小数 Excel的列 日期数 取数 最大连通块 编程题 一周第几天 被覆盖的点 未被清理的区域 滑行距离 区间最小值 本篇文章中的题解是我在比赛中的思路或者所写的代码, 总结出的一 ...

  5. 第十二届蓝桥杯校内模拟赛记录12月26日

    文章目录 前言 第1题 第2题 第3题 第4题 第5题 第6题 第7题 第8题 第9题 第10题 前言 部分题目无法通过全部测试样例,待优化. 第1题 问题描述 如果整数 a 是整数 b 的整数倍,则 ...

  6. 【c语言】2020蓝桥杯校内模拟赛c组

    求1200000的约数有多少?(只计算正约数) #include <stdio.h> int main(int argc, char *argv[]) {int n,i,k=0;print ...

  7. 2020蓝桥杯校内模拟赛1-5(详细版本,看完就会)

    1.题目: 问题描述 在计算机存储中,15.125GB是多少MB? 答案提交 这是一道结果填空的题,你只需要算出结果后提交即可.本题的结果为一个整数. 学习计算机的人都知道1GB=1024MB(2的1 ...

  8. 2021年 第十二届蓝桥杯第二期校内模拟赛题解(Java版)

    时隔多日,终于会写一些简单DP了哈哈哈! 稍微改版,方便阅读,若有错,请指出 2019年 第十届蓝桥杯省赛题解(JavaB组版) 2020年 第十一届蓝桥杯第一场省赛题解(JavaB组版) 2020年 ...

  9. 2020年蓝桥杯省模拟赛

    2020年4月18日蓝桥杯省模拟赛 第一题: 问题描述: 由1对括号,可以组成一种合法括号序列:(). 由2对括号,可以组成两种合法括号序列:()().(()). 由4对括号组成的合法括号序列一共有多 ...

最新文章

  1. 杭州/北京/新加坡 | 蚂蚁集团数字身份团队招聘计算机视觉算法实习生
  2. jvm 崩溃日志设置_记一次JVM疯狂GC导致CPU飙高的问题解决
  3. 辐射避难所买了东西显示服务器异常,《辐射:避难所》常见问题汇总
  4. 我的U盘,在某台机器上所有文件大小为0
  5. python发明小故事简写_科学发明小故事10字以上
  6. Endnote X8激活注册信息
  7. html渐变做一个彩虹,ps渐变工具:制作七色彩虹特效
  8. 怎样在电脑上下载哔哩哔哩的视频?
  9. 党² - 李超线段树
  10. JAVA毕业设计健身房信息管理系统计算机源码+lw文档+系统+调试部署+数据库
  11. 地址解析(仅供参考与学习)<Java>
  12. 用python模拟一个文本浏览器来抓取网页
  13. 【Multisim仿真】有源低通滤波电路仿真
  14. 记录一下接多盟SDK遇到的问题
  15. 干货!实战!你领取的优惠券都是怎么样实现的?
  16. python里order什么意思_order是什么意思?看完我有点懵圈儿
  17. python ==module 'datetime' has no attribute 'strptime'
  18. 智慧零售解决方案-最新全套文件
  19. 迈拓维矩亮相2019北京InfoComm视听系统集成展
  20. 计算机硕士全国联考英语考试,在职攻读硕士学位全国联考英语考试大纲有这五大内容需要注意...

热门文章

  1. 杭电数电实验(五)流水灯实验
  2. 微信上赚钱需要准备什么?
  3. js调用app下载或者打开app(手机下载或者打开新的页面)
  4. 一起来看流星雨-------张翰
  5. 什么是Ethereum以太坊(ETH)?以及以太坊的一些基础知识
  6. 程序员如何进入人工智能和大数据领域
  7. // 完整的COM例子
  8. 信号 信号的线性放大
  9. mysql入门视频 吾_学习猿地-全网最新版本MySQL8全套视频教程(学完这个课 MySQL 就精通了)...
  10. Unity3D博客及论坛合集