First question :

Problem description

Here is an example 25 that 's ok 25 Alphabetic matrix of columns , All by letters A and B form .

AAAAAAABABBAABABABAAAAAAA

ABBBBBABBAABBBBBABABBBBBA

ABAAABABBBABAABBBBABAAABA

ABAAABABBBBBAABAABABAAABA

ABAAABABBABABBABABABAAABA

ABBBBBABBBABAABBBBABBBBBA

AAAAAAABABABABABABAAAAAAA

BBBBBBBBABAABABBBBBBBBBBB

AABAABABBAAABBAAABABBBBBA

ABBABABBBABBAAAABBBBAAAAB

BBBBAAABABAABABAABBBAABBA

BBAABABABAAAABBBAABBAAAAA

ABABBBABAABAABABABABBBBBA

AAAABBBBBABBBBAAABBBABBAB

AABAABAAABAAABAABABABAAAA

ABBBBBBBBABABBBBABAABBABA

ABBBAAABAAABBBAAAAAAABAAB

BBBBBBBBABBAAABAABBBABBAB

AAAAAAABBAAABBBBABABAABBA

ABBBBBABBAABABAAABBBABBAA

ABAAABABABBBAAAAAAAAAABAA

ABAAABABABABBBABBAABBABAA

ABAAABABBABBABABAABAABAAA

ABBBBBABABBBBBABBAAAABAAA

AAAAAAABAABBBAABABABBABBA

How many letters are there in this matrix A?

#include<bits/stdc++.h> #define ll long long using namespace std; char s[625];
void solve() { cin >> s; ll ans = 0; for (int i = 0; i < 625; i++) { if (s[i]
== 'A') ans++; } cout << ans; } int main() { solve(); return 0; }
open txt Delete all the carriage returns in the text and read the output answer

If a digit of an integer contains 2 , Then call this number one “ most 2 number ”. for example :102,2021 Are the most 2 number .

Excuse me 1( contain ) reach 2021( contain ) in , How many are the most important 2 number .

#include<bits/stdc++.h> #define ll long long using namespace std; bool
zui2(int a) { while(a) { int t = a % 10; a /= 10; if (t == 2) return true; }
return false; } void solve() { int ans = 0; for (int i = 1; i <= 2021; i++) {
if (zui2(i)) ans++; } cout << ans; } int main() { solve(); return 0; }
Question 3 :

Problem description

There is an integer A=2021, every time , You can add this number 1 , reduce 1 Or divided by 2, Where divided by 2 It is allowed only when the number is even .

for example ,2021 After one operation, it can become 2020,2022.

Another example ,2022 After one operation, it can become 2021,2023 or 1011.

Excuse me? ,2021 At least how many operations can it become 1.

Divide even numbers 2, Odd number -1.
#include<bits/stdc++.h> #define ll long long using namespace std; void solve()
{ int a = 2021; int ans = 0; while(a != 1) { if (a & 1) a--, ans++, cout << a
<< endl; else { a /= 2; ans++; cout << a << endl; } } cout << ans; } int main()
{ solve(); return 0; }
Question 4 :

Problem description

For a n that 's ok m Column table , We can use the spiral method to fill in positive integers in the form in turn , We call the filled form a spiral matrix .

for example , One 4 that 's ok 5 The spiral matrix of the column is as follows :

1 2 3 4 5

14 15 16 17 6

13 20 19 18 7

12 11 10 9 8

Excuse me? , One 30 that 's ok 30 Spiral matrix of columns , The first 20 Line number 20 What is the value of the column ?

Printing of spiral matrix , If not, the code can be used excel Make a watch ha ha .

ans:819

#include<bits/stdc++.h> #define ll long long using namespace std; int
dp[200][200]; void solve(int n) { int loop = n / 2; int mid = n / 2; int offset
= 1; int k = 1; int startx = 0, starty = 0; while (loop--) { int i = startx;
int j = starty; for (j = starty; j < starty + n - offset ; j++) { dp[startx][j]
= k++; } for (i = startx; i < n - offset + startx; i++) { dp[i][j] = k++; } for
(; j > starty; j--) { dp[i][j] = k++; } for (; i > startx; i--) { dp[i][j] =
k++; } offset += 2; startx++, starty++; } if (n & 1) dp[mid][mid] = n * n; for
(int i = 0;i<n;i++) { for (int j = 0; j<n;j++) cout << dp[i][j]<< " "; cout <<
endl; } } int main() { solve(30); return 0; }

Question 5 :

Problem description

A binary tree has 2021 Nodes . The tree satisfies that the difference between the number of left subtree nodes and the number of right subtree nodes of any node is up to 1.

Define the depth of the root node as 0, The depth of the child node is more than that of the parent node 1.

Excuse me? , What is the maximum possible depth of the deepest node in the tree ?

According to the meaning of the title, this binary tree is close to a complete binary tree , According to the formula of complete binary tree , Depth is k The number of binary tree nodes is  2^k - 1;

2^11 = 2048,  2^10 = 1024;  Simply draw a binary tree with three nodes 2^2  - 1= 3, Depth is 1( Because the root node depth is 0)

So the depth of the answer is 11-1 = 10

Question 6 :

Problem description

A monk wants to carry water , You can pick at most every time a Kilogram , The water tank can be installed at most t Kilogram , The water tank is empty at the beginning .

How many times does the monk have to pick at least to fill the water tank ?

Input format

The input line contains two integers a, t, Separated by a space .

Output format

The output line contains an integer , Indicates the answer .

sample input

20 2021

sample output

102

Scale and agreement of evaluation cases

For all profiling cases ,1 <= a <= 100,1 <= t <= 10000.

Simple simulation be careful n When it is an odd number +1
#include<bits/stdc++.h> #define ll long long using namespace std; int a, t;
void solve() { cin >> a >> t; int ans = t / a; if (t % a != 0) { ans++; } cout
<< ans; } int main() { solve(); return 0; }

Question 7 :

Problem description

In the financial field , The amount is usually between the hundreds and thousands , Add commas between 100000 and millions ( Thousands separator ), To facilitate reading . Generally, it starts from a single bit , Add a comma before every three digits .

for example :1234567890.00 Usually written as 1,234,567,890.00.

Pay attention to the fixed retention after the decimal point 2 position .

Give a numeric value that contains a thousand separator , Please read in and output the corresponding value without thousands , The decimal point remains 2 position .

Input format

Enter a line containing a numeric value separated by a thousandth separator , Happen to have 2 Decimal place .

Output format

Outputs a numeric value without a thousand separator , retain 2 Decimal place .

sample input

1,234,567,890.00

sample output

1234567890.00

Scale and agreement of evaluation cases

For all profiling cases , The integer part of the given value does not exceed 12 position .

thinking : Enter as string , Just delete all commas .
#include<bits/stdc++.h> #define ll long long using namespace std; string s;
void solve() { cin >> s; while(s.find(',') != string::npos) { int pos =
s.find(','); s.erase(pos, 1); } //s.erase(3, 1); cout << s; } int main() {
solve(); return 0; }

Question 8 :

Problem description

Xiaolan has a plug-in board , Shape with a n * m of 01 Matrix representation ,0 Represents the board surface ,1 Represents the jack .

Xiaolan also has a plug , Shape with a r * c of 01 Matrix representation ,0 Indicates that there is no protruding part ,1 Indicates the protruding part . The protruding part of the plug must be inserted into the socket .

For safety , When the plug is inserted into the panel, no part can exceed the boundary of the plug board ( Including parts that do not protrude ).

Neither the plug nor the plug plate can rotate , You can't flip . Request the reasonable position of the plug into the plug board .

Input format

The first line of input contains two integers n, m.

next n that 's ok , Each line has a length of m of 01 strand , Indicates the shape of the plug-in board .

The next line contains two integers r, c.

next r that 's ok , Each line has a length of c of 01 strand , Indicates the shape of the plug .

Output format

If the plug cannot be safely inserted into the plug board , output “NO”. Otherwise, two numbers are output a, b, Indicates the second dimension of the plug 1 Line number 1 Column corresponding to the plug-in board a Line number b
column . If there are multiple situations that meet the requirements , output a Minimal scheme , If a There are multiple minimum schemes , Output in a On the premise of minimum b Minimal scheme .

sample input

3 4

0110

0000

0000

3 3

000

010

000

sample output

NO

Example description

The plug cannot be inserted without exceeding the range .

sample input

4 7

1110100

1101111

0001111

0000011

2 3

111

011

sample output

2 4

Scale and agreement of evaluation cases

about 50% Evaluation cases for ,2 <= n, m, r, c <= 20.

For all profiling cases ,2 <= n, m, r, c <= 100.

Pay attention to the boundary and then simulate ... One at a time  ’1‘ Then compare
#include<bits/stdc++.h> #define ll long long using namespace std; int n, m,
r,c; string chazuo[101]; string chatou[101]; int pipei; bool check(int posx,
int posy, int x, int y) { //cout << endl; int cnt = 0; int k = posx; int l =
posy; if (m - posy < c || n - posx + 1 < r) return false; for (int i = x; i <
r; i++) { for (int j = y; j < c ;j++) { if (chazuo[k][l]=='1' && chatou[i][j]
== '1') { l++; cnt++; } else if (chatou[i][j] == '0') { l++; } else if
(chatou[i][j] == '1' && chazuo[k][l] == '0') return false; if (cnt == pipei) {
return true; } //cout << i << " Plug " << j << " " << k << " Socket " << l - 1 << "
count " << cnt << endl; } k++; l = posy; } return false; } void solve() { cin >> n
>> m; for (int i = 0; i < n; i++) { cin >> chazuo[i]; } cin >> r >> c; for (int
i = 0; i < r; i++) { cin >> chatou[i]; } for (int i = 0; i < r; i++) { for (int
j = 0; j < c; j++) { if (chatou[i][j] == '1') pipei++; } } //cout << check(0,
0, 0, 0) << endl; int gapRow = n - r; int gapCol = m - c; if (gapRow < 0 ||
gapCol < 0) { cout << "NO"; return; } int first_OnechatouX; int
first_OnechatouY; //string first; for (int i = 0; i < r; i++) { if
(chatou[i].find('1') != string::npos) { first_OnechatouX = i; first_OnechatouY
= chatou[i].find('1'); //first = chatou[i].substr() break; } } //printf("%d,%d
%d\n", first_OnechatouX, first_OnechatouY, pipei); for (int i = 0; i < n; i++)
{ if (first_OnechatouX > i) continue; for (int j = 0; j < m; j++) { if
(chazuo[i][j] == '1') { if (check(i, j, first_OnechatouX, first_OnechatouY)) {
cout << i + 1 << " " << j + 1; return; } } } } cout << "NO"; return; } int
main() { solve(); //system("pause"); return 0; }
Question 9 :

Problem description

Given positive integer a, b, c, How many positive integers are there , Is the divisor of at least two of them .

Input format

The input line contains three positive integers a, b, c.

Output format

The output line contains an integer , Indicates the answer .

sample input

30 70 35

sample output

6

Example description

1,2,5,7,10,35 Meet the conditions .

Scale and agreement of evaluation cases

about 50% Evaluation cases for ,1 <= a, b, c <= 1000000.

For all profiling cases ,a, b, c No more than 10**12(10 of 12 Power ).

According to the meaning of the title , Get some points with violence ....
#include<bits/stdc++.h> #define ll unsigned long long using namespace std; ll
a, b, c; ll ans; map<ll, ll> m; void solve() { //ll ans = 0; cin >> a >> b >>
c; ll ta = a, tb = b, tc = c; ll Max = max(a, b); for (int i = 1; i <= Max;
i++) { if (ta % i == 0 && tb % i == 0 && m[i] == 0) { m[i] = 1,ans++;; //m[i] =
1; //cout << i << " "; //ta /= i; tb /= i; } } Max = max(a, c); ta = a; for
(int i =1; i <= Max; i++) { if (ta % i == 0 && tc % i == 0&& m[i] == 0) { m[i]
= 1,ans++;; //m[i] = 1; //cout << i << " "; //ta /= i; tc /= i; } } tc = c; for
(int i =1; i <= Max; i++) { if (tc % i == 0 && tb % i == 0&& m[i] == 0) { m[i]
= 1, ans++;; //m[i] = 1; //cout << i << " "; //tb /= i; tc /= i; } } cout
<<ans; } int main() { solve(); return 0; }
No question 10

Question 10 :

Problem description

Xiao Lan likes playing tower of Hanoi very much .

There are three pillars in the game , At the beginning, there was on the first column n Disc , The size of the disc from top to bottom is 1 reach n.

every time , You can move a plate from one post to another , This plate must be the plate at the top of the column , And the plate moved to the post must be larger than this plate .

Xiaolan's goal is to move all the plates to the third post .

The tower of Hanoi is a classic question , When the number of plates is n Time , Minimum movement required 2**n-1 step , among 2**n express 2 of n Power .

Xiao Lan has been playing for a while ( Not necessarily according to the best plan ), He wants to know , For his current situation , How many more steps are needed to reach the goal .

Input format

The first line of input contains three nonnegative integers a, b, c, Respectively represent the number of plates on each column at present . In this question ,n=a+b+c.

The second line contains a Integer , Adjacent integers are separated by a space , Represents the plate on the first post , Press the plate from top to bottom ( from small to large ) The order of is given .

The third line contains b Integer , Adjacent integers are separated by a space , Represents the plate on the second post , Press the plate from top to bottom ( from small to large ) The order of is given .

The fourth line contains c Integer , Adjacent integers are separated by a space , Represents the plate on the third post , Press the plate from top to bottom ( from small to large ) The order of is given .

Output format

The output line contains an integer , Indicates the answer .

sample input

1 2 3

1

2 3

4 5 6

sample output

7

Scale and agreement of evaluation cases

about 30% Evaluation cases for ,2 <= n <= 5.

For all profiling cases ,2 <= n <= 60.

Technology
Daily Recommendation
views 267
views 232
views 231