<> Filling in the blanks of the 12th Blue Bridge Cup 1.2 Problem solving ideas

For the first time, I published my blog and my problem-solving experience. If there are mistakes, please explain and help me a lot
* First question
【 Problem description 】
Xiaolan is ready to use 256MB Open an array in the memory space of , Every element of the array is 32 position
Binary integer , If the space occupied by the program and the auxiliary space required to maintain memory are not considered , Excuse me?
256MB How many can you store in your space 32 Bit binary integer ?

thinking ： about 1MB=1024KB( Kilobyte )=1024 ride 1024b( byte )=1024 ride 1024 ride 8 individual bit( binary digit ),1 Bytes equal 8 Bits , so 256MB Can store 256 ride 1024 ride 1024 except 4 individual 32 Bit binary integer ;

* Second question
【 Problem description 】
Xiaolan has many digital cards , There are numbers on every card 0 reach 9.
Xiao Lan is going to spell some numbers with these cards , He wants to start from 1 Start spelling positive integers , Each spell one ,
Just keep it , Cards can't be used to spell other numbers .
Xiaolan wants to know what she can do from 1 How much do you spell .
for example , When Xiaolan has 30 Card , among 0 reach 9 various 3 Zhang , Then little blue can spell 1 reach 10,
But spell 11 Time card 1 There's only one , Not enough spelling 11.
Now Xiaolan has it in her hand 0 reach 9 Each card 2021 Zhang , common 20210 Zhang , Can Xiaolan go from 1
How much do you spell ?

thinking ： For this question, first 0-9 The cards are stored in an array , Separately s[0]-s[9] Assigned as the number of each card , Then, determine the number of each digit by looping , If the number is used once, the value of the number array is subtracted once , Until for 0 End of cycle , The code is as follows
code ：`#include
#include
using namespace std;
int res;
int main()
{
bool flag; int s[10];// preservation 0-9 Number of cards int i; for(i=0;i<=9;i++) { s[i]=2021; }
while(1) { int t=res; while(t)// Determine the number of each digit that makes up the number { if(!s[t%10]) { flag=true;
break;// The digital card is used up and the cycle ends } s[t%10]--; t/=10; } if(flag) { break; } res++; }
cout<<res-1;//-1 It is impossible to determine the composition of the previous card because it is composed of numbers -1 Is the previous number return 0;
}
`

Technology
Daily Recommendation
views 1