Blue Bridge Cup Brush Questions ①

Foreword: Hello, all children and students! Long time no see! This article is my blue bridge cup OJ writing notes! The article belongs to the column Blue Bridge Cup. The purpose of this column is to record your record of writing questions and the learning process, to motivate yourself to keep moving forward, and to prepare for next year's ACM, ICPC, Blue Bridge Cup and other competitions. I also hope that it can help Meet some friends who are also on the road of brushing the questions! ! ! !

insert image description here

1. Word analysis

Title description
Xiaolan is learning a magical language. The words in this language are all composed of lowercase English letters, and some words are very long, far exceeding the length of normal English words. Xiaolan couldn't remember some words after studying for a long time. He planned not to memorize these words completely, but to distinguish words according to which letter appeared the most in the word.

Now, please help Xiaolan. After giving a word, help him find the letter that appears the most and the number of times this letter appears.

Input description
Input a line containing a word, and the word is only composed of lowercase English letters.

For all evaluation cases, the input word length does not exceed 1000.

Output description
Output two lines, the first line contains an English letter, indicating which letter appears most frequently in the word. If there are multiple letters with the same number of occurrences, output the one with the smallest lexicographical order.

The second line contains an integer representing the number of occurrences of the most frequent letter in the word.

input output example
example 1
input

lanqiao
copy
output

a
2
copy
example 2
input

longlonglongistoolong
copy
output

o
6

AC code:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    
    string s;
    int max=0,a[26]={
    
    0};
    char c;
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
    
    
        a[s[i]-'a']++;
    }
    for(int i=0;i<26;i++)
    {
    
    
        if(a[i]>max)
        {
    
    
            max=a[i];
            c=i+'a';
        }
    }
    cout<<c<<endl;
    cout<<max<<endl;
    return 0;
}

2. Statistics

Description of the topic
Xiaolan organized an exam for the students. The total score of the paper is 100 points, and each student's score is an integer from 0 to 100.

A score of at least 60 is called a pass. A score of at least 85 is considered excellent.

Please calculate the pass rate and excellent rate, expressed as a percentage, and the part before the percentage sign is rounded to an integer.

Input Description
The first line of input contains an integer

n (1≤n≤10 4 ), represents the number of people taking the test.

next

n lines, each line contains an integer from 0 to 100, representing a student's score.

Output description
Output two lines, each with a percentage, indicating the passing rate and the excellent rate respectively. The part before the percent sign is rounded to an integer.

Input and output sample
example
input

7
80
92
56
74
88
100
0
copy
output

71%
43%

AC code:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    
    int n;
    int grade;
    int sum1=0,sum2=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
    
    
        cin>>grade;
        if(grade>=60)
        {
    
    
            sum1+=1;
        }
        if(grade>=85)
        {
    
    
            sum2+=1;
        }
    }
    sum1=sum1*100.0/n*1.0+0.5;
    sum2=sum2*100.0/n*1.0+0.5;
    printf("%d%%\n%d%%",sum1,sum2);
}

3, the shortest path

Title Description
This question is a fill-in-the-blank question. You only need to calculate the result and use the output statement in the code to output the filled result.

As shown in the figure below,
G is an undirected graph where the length of the blue side is 1 and the length of the orange side is 2 and the length of the green side is 3.

image description

What is the shortest distance from A to S?

AC code:

#include <iostream>
using namespace std;
int main()
{
    
    
  printf("6");
  return 0;
}

4. Door plate making

Title Description
This question is a fill-in-the-blank question. You only need to calculate the result and use the output statement in the code to output the filled result.

Xiaolan wants to make house numbers for the residents of a street.


There are a total of 2020
2020 residents on this street , and the house numbers are numbered from 1 to 2020.

The way Xiaolan makes the house number is to make

0 to

9 These numbers and characters, and finally paste the characters on the house number as needed, for example, the house number 1017 needs to paste the characters one by one

1, 0, 1, 7, that is required

1 character 0, 2 characters 1, 1 character 7.

May I ask how many characters 2 are needed to make all the house numbers from 1 to 2020?

AC code:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    
    int count=0;
    int t;
    for(int i=1;i<=2020;i++)
    {
    
    
        t=i;
        while(t)
        {
    
    
            if(t%10==2)
            {
    
    
                count++;
                
            }
            t/=10;
        }
    }
    cout<<count;
}

5. Cards

Title Description
This question is a fill-in-the-blank question. You only need to calculate the result and use the output statement in the code to output the filled result.

Xiaolan has a lot of number cards, and each card has the numbers 0 to 9 on it.

Xiaolan is going to use these cards to spell some numbers, he wants to start from

1 Start to spell out positive integers, save each one, and the cards cannot be used to spell other numbers.

Xiaolan wants to know how much she can spell from 1.

For example, when Xiaolan has 30 cards, including 3 cards from 0 to 9, Xiaolan can spell out 1 to 10,

But when spelling
11 11 , there is only one
card
1 1, which is not enough to spell 11 11.


Now Xiaolan has 2021 2021 cards from
0
0 to
9
9 in his hand , a total of 20210 20210 cards, how many cards can Xiaolan get from 1 1?





Tip: It is recommended to use computer programming to solve the problem.

AC code:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    
    int num[10];
    for(int i=0;i<10;i++)
    {
    
    
        num[i]=2021;
    }
    for(int i=1;;i++)
    {
    
    
        int x=i;
        while(x)
        {
    
    
            if(num[x%10]==0)
            {
    
    
                cout<<i-1;
                return 0;
            }
            num[x%10]--;
            x/=10;    
        }
    }
    return 0;
}

6. Numeral triangle

Title Description
insert image description here
The figure above shows a digital triangle. There are many different paths from the top to the bottom of the triangle. For each path, add up the numbers on the path to get a sum, and your task is to find the largest sum.

Each step on the path can only go from one number to the next level and its closest left or right number. In addition, the number of times to go down to the left and the number of times to go down to the right cannot differ by more than 1.

Input Description
The first line of input contains an integer

N (1≤N≤100), indicates the number of rows of the triangle.

The next N lines give the numeric triangle. The numbers on the number triangle are all integers between 0 and 100.

Output Description
Output an integer representing the answer.

Input and output sample
example
input

5
7
3 8
8 1 0
2 7 4
4 4 5 2 6 5
copy
output

27

AC code:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    
    int e[101][101];
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    
    
        for(int j=1;j<=i;j++)
        {
    
    
            cin>>e[i][j];
        }
    }
    for(int i=2;i<=n;i++)
    {
    
    
        for(int j=1;j<=i;j++)
        {
    
    
            e[i][j]+=max(e[i-1][j],e[i-1][j-1]);
        }
    }
    if(n%2 == 0)
    {
    
    
        cout << max(e[n][n/2],e[n][n/2+1]);
    }
    else
    {
    
    
        cout << e[n][n/2+1];
    }
}

7. Score Analysis

Description of the topic
Xiaolan organized an exam for the students. The total score of the paper is 100 points, and each student's score is an integer from 0 to 100.

Please calculate the highest, lowest and average scores for this test.

Input Description
The first line of input contains an integer

n (1≤n≤10 4 ), represents the number of people taking the test.

next

n lines, each line contains an integer from 0 to 100, representing a student's score.

Output Description
Outputs three lines.

The first line contains an integer representing the highest score.

The second line contains an integer representing the minimum score.

The third line contains a real number, rounded to retain exactly two decimal places, indicating the average score.

Input and output sample
example
input

7
80
92
56
74
88
99
10
copy
output

99
10
71.29

AC code:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    
    int n;
    int max=0,min=100;
    double aver;
    int grade;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    
    
        cin>>grade;
        aver+=grade;
        if(grade>max)
        {
    
    
            max=grade;
        }
        if(grade<min)
        {
    
    
            min=grade;
        }
    }
    cout<<max<<endl<<min<<endl;
    printf("%.2lf",aver/n);
}

8. Shopping list

Title Description
This question is a fill-in-the-blank question. You only need to calculate the result and use the output statement in the code to output the filled result.

Xiao Ming has just found a job, and the boss is very nice, but his wife loves shopping very much. When the boss is busy, he often asks Xiao Ming to help him go shopping in the mall. Xiao Ming is very bored, but it is not easy to refuse.

No, the big sale is here again! The boss's wife made out a long shopping list, all of which had discounts.

Xiao Ming also has a quirk. Unless it is a last resort, he never swipes his card and pays directly in cash.

Now Xiao Ming is very upset, please help him calculate how much cash he needs to withdraw from the ATM to complete this shopping.

ATMs can only dispense
100
100-yuan notes. Xiao Ming wants to withdraw as little cash as possible, as long as it is enough. Your task is to calculate the minimum amount of cash that Xiao Ming needs to withdraw.

The following is a headache shopping list, to protect privacy, item names are hidden.

**** 180.90 12% off
**** 10.25 65% off
**** 56.14 10% off
**** 104.65 10% off
**** 100.30 12% off
**** 297.15 half price
**** 26.75 35% off
** ** 130.62 half price
**** 240.28 52% off
**** 270.62 20% off **** 115.87 12% off **** 247.34
55% off **** 73.21 10% off **** 101.00 half price **** 79.54 Half price **** 278.44 30% off **** 199.26 half price **** 12.97 10 % off **** 166.30 22% off **** 125.50 52% off **** 84.98 10% off **** 113.35 32% off * *** 166.57 half price **** 42.56 10% off **** 81.90 15% off **** 131.78 20% off **** 255.89 22% off **** 109.17 10% off **** 146.69 32% off *** * 139.33 35% off



















**** 141.16 72% off
**** 154.74 20% off
**** 59.42 20% off ****
85.44 62% off
**** 293.70 12% off
**** 261.79 65% off
**** 11.30 12% off
* *** 268.27 52% off
**** 128.29 12% off
**** 251.03
20% off **** 208.39 25% off
**** 128.88 25% off ****
62.06 10% off
**** 225.87 25% off
** ** 12.89 25% off
**** 34.28 75% off
**** 62.16 52% off
**** 129.12 half price
**** 218.37 half price ****
289.69 20%
off

12% off refers to the listed price

88 calculations, while

20% off is by

80 calculations, and the rest by analogy. In particular, half price is based on

50 calculations.

Please input the amount that Xiao Ming wants to withdraw from the ATM, in yuan.

AC code:

#include <iostream>
using namespace std;
int main()
{
    
    
  cout<<5200;
  return 0;
}

9. Space

This question is a fill-in-the-blank question. After calculating the result, use the output statement in the code to output the filled result.

Xiaolan is ready to use

256MB of memory space to open an array, each element of the array is

32-bit binary integer, if the space occupied by the program and the auxiliary space required for maintaining the memory are not considered, please ask

How many can be stored in 256MB

32-bit binary integer?

AC code:

#include <iostream>
using namespace std;
int main()
{
    
    
  long long sum=256*1024*1024/4;
  cout<<sum;
  return 0;
}

10. Sorting

Title Description
This question is a fill-in-the-blank question. You only need to calculate the result and use the output statement in the code to output the filled result.

Xiaolan recently learned some sorting algorithms, among which bubble sort impressed him deeply.

In bubble sort, only two adjacent elements can be exchanged at a time.

Xiaolan found that if the characters in a string are sorted and only two adjacent characters are allowed to be exchanged, then among all possible sorting schemes, the total number of exchanges of bubble sorting is the least.

For example, to sort the string � � � lan
1 1 swaps are required. For sorting the string � � � qiao 4 4 swaps are required.











Xiaolan found a lot of strings and tried to sort them. He happened to encounter a string that needed
100
100 exchanges, but he forgot to write down this string, and now he can't find it.

Please help Xiaolan find a string that contains only lowercase English letters and no repeated letters. Sorting the characters of this string requires exactly
100
100 exchanges. If you can find more than one, please tell Xiaolan the shortest one. If there are still multiple shortest ones, please tell Xiaolan the one with the smallest lexicographical order.

AC code:

#include <stdio.h>
#include <stdlib.h>
int main()
{
    
    
    int i,m,t,j;
    int n=0;
    while((n*n-n)/2<100)n++;
    m=(n*n-n)/2-100;
    char arr[n];
    for(i=0;i<n;i++)arr[i]=97+n-i-1;
    for(i=m;i>0;i--)
    {
    
    
        if(arr[i]<arr[i-1])
        {
    
    
            t=arr[i];
            arr[i]=arr[i-1];
            arr[i-1]=t;
        }
    }
    for(i=0;i<n;i++)
    {
    
    
        printf("%c",arr[i]);
    }
  return 0;
}

11. Run for exercise

Title Description
This question is a fill-in-the-blank question. You only need to calculate the result and use the output statement in the code to output the filled result.

Xiaolan exercises every day.

Under normal circumstances, Xiaolan runs
11
kilometers every day. If a certain day falls on a Monday or the beginning of the month (
11th
), in order to motivate herself, Xiaolan will run
22
kilometers. If it is Monday or the beginning of the month at the same time, Xiaolan will also run
22
kilometers.

Xiaolan has been running for a long time, from Saturday, November 11 , 2000 (inclusive) in
2000 to Thursday, October 11 , 2020 (inclusive) in 2020 . How many kilometers did Xiaolan run in total during this period?










AC code:

#include<iostream>
using namespace std;
int main()
{
    
    
    int week[7]={
    
    6,7,1,2,3,4,5};
    int month[13]={
    
    0,31,0,31,30,31,30,31,31,30,31,30,31};
    int sum=0,day=0;
    for(int year=2000;year<=2020;year++)
    {
    
    
        if( (year%4==0&&year%100!=0) ||year%400==0  )
            month[2]=29;
        else
            month[2]=28;
        for(int i=1;i<=12;i++)
        {
    
    
            for(int j=1;j<=month[i];j++)
            {
    
    
                if(week[day%7]==1||j==1)
                    sum++;
                sum++;
                day++;
                if(year==2020&&i==10&&j==1)
                {
    
    
                    cout<<sum;
                    return 0;
                }
            } 
        } 
    }
}

12. Serpentine filling

Title Description
This question is a fill-in-the-blank question. You only need to calculate the result and use the output statement in the code to output the filled result.

As shown in the figure below, Xiao Ming fills the infinite matrix with positive integers starting from
1 1 in a "snake shape".

1 2 6 7 15 …
3 5 8 14 …
4 9 13 …
10 12 …
11 …

copy
It is easy to see that the number in the second row and second column of the matrix is
​​5
5. Please calculate the number in row
20
20 and column
20 20 in the matrix?

AC code:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    
    int mp[101][101],row=0,col=0,cnt=1;
    mp[0][0]=1;
    while(!mp[19][19])
    {
    
    
        mp[row][++col]=++cnt;
        while(col)
        {
    
    
            mp[++row][--col]=++cnt;
        }
        mp[++row][col]=++cnt;
        while(row)
        {
    
    
            mp[--row][++col]=++cnt;
        } 
    }
    cout<<mp[19][19];
    return 0;
}

13. Incremental sequence

Title Description
This question is a fill-in-the-blank question. You only need to calculate the result and use the output statement in the code to output the filled result.

For a letter matrix, we call an increasing sequence in the matrix means to find two letters in the matrix, they are in the same row, the same column, or on the same
45
45 degree slant, the two letters are from left to right Looking at, or looking from top to bottom is incremental.

For example, in the following matrix

LANN
QIAO
copy
has 13 13 increasing sequences
such as LN, LN, AN, AN, IO, AO, LQ, AI, NO, NO, AQ, IN, AN, etc. Note that when the two letters are arranged from bottom left to top right, the order is different when looking from left to right and from top to bottom.

For the following matrix with
30
30 rows and
50
50 columns, how many increasing sequences are there in total?

VLPWJVVNNZSWFGHSFRBCOIJTPYNEURPIGKQGPSXUGNELGRVZAG
SDLLOVGRTWEYZKKXNKIRWGZWXWRHKXFASATDWZAPZRNHTNNGQF
ZGUGXVQDQAEAHOQEADMWWXFBXECKAVIGPTKTTQFWSWPKRPSMGA
BDGMGYHAOPPRRHKYZCMFZEDELCALTBSWNTAODXYVHQNDASUFRL
YVYWQZUTEPFSFXLTZBMBQETXGXFUEBHGMJKBPNIHMYOELYZIKH
ZYZHSLTCGNANNXTUJGBYKUOJMGOGRDPKEUGVHNZJZHDUNRERBU
XFPTZKTPVQPJEMBHNTUBSMIYEGXNWQSBZMHMDRZZMJPZQTCWLR
ZNXOKBITTPSHEXWHZXFLWEMPZTBVNKNYSHCIQRIKQHFRAYWOPG
MHJKFYYBQSDPOVJICWWGGCOZSBGLSOXOFDAADZYEOBKDDTMQPA
VIDPIGELBYMEVQLASLQRUKMXSEWGHRSFV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WEAJOISPFPLULIWVVALLIIHBGEZLGRHRCKGF",\
"LXYPCVPNUKSWCCGXEYTEBAWRLWDWNHHNNNWQNIIBUCGUJYMRYW",\
"CZDKISKUSBPFHVGSAVJBDMNPSDKFRXVVPLVAQUGVUJEXSZFGFQ",\
"IYIJGISUANRAXTGQLAVFMQTICKQAHLEBGHAVOVVPEXIMLFWIYI",\
"ZIIFSOPCMAWCBPKWZBUQPQLGSNIBFADUUJJHPAIUVVNWNWKDZB",\
"HGTEEIISFGIUEUOWXVTPJDVACYQYFQUCXOXOSSMXLZDQESHXKP",\
"FEBZHJAGIFGXSMRDKGONGELOALLSYDVILRWAPXXBPOOSWZNEAS",\
"VJGMAOFLGYIFLJTEKDNIWHJAABCASFMAKIENSYIZZSLRSUIPCJ",\
"BMQGMPDRCPGWKTPLOTAINXZAAJWCPUJHPOUYWNWHZAKCDMZDSR",\
"RRARTVHZYYCEDXJQNQAINQVDJCZCZLCQWQQIKUYMYMOVMNCBVY",\
"ABTCRRUXVGYLZILFLOFYVWFFBZNFWDZOADRDCLIRFKBFBHMAXX"};
  int s=0;
  for(int i=0;i<30;i++)
    for(int j=0;j<50;j++)
      for(int x=0;x<30;x++)
        for(int y=0;y<50;y++)
          if(v[i][j]<v[x][y]&&((i==x&&y>j)||(j==y&&x>i)||abs(y-j)==abs(x-i)&&!(x<=i&&y<=j)))
            s++;
  cout<<s;
}

14. Cargo placement

Title description
Xiaolan has a super large warehouse that can store a lot of goods.

Now, Xiaolan has

N boxes of goods should be placed in the warehouse, and each box of goods is a regular cube. Xiaolan stipulates three mutually perpendicular directions of length, width, and height. The sides of each box of goods must be strictly parallel to the length, width, and height.

Xiaolan hopes that all the goods will eventually be arranged in a big cuboid. That is, pile up in the directions of length, width and height

L, W, H goods, meet

n=L×W×H。

given

n, how many schemes of stacking goods are there to meet the requirements.

For example, when

4
When n=4, there are
6
6 schemes as follows:
1×1×4, 1×2×2, 1×4×1, 2×1×2, 2×2×1, 4×1×1.

Excuse me, when

When 2021041820210418
n=2021041820210418 (note that there are
16
16 digits), how many schemes are there in total?

Tip: It is recommended to use computer programming to solve the problem.

Submit the answer
This is a question of filling in the blank with the result, you only need to calculate the result and submit it. The result of this question is an integer, only fill in this integer when submitting the answer, filling in redundant content will result in no scoring.

AC code:

#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
int main()
{
    
    
    long long n=2021041820210418;
    vector<long long>divisor;
    for(long long i=1;i<=sqrt(n);i++)
    {
    
    
        if(n%i==0)
        {
    
    
            divisor.push_back(i);
            long long k=n/i;
            if(k!=i)
                divisor.push_back(k);
        }
    }
    int count=0;
    vector<long long>::iterator a,b,c;
    for(a=divisor.begin();a!=divisor.end();a++)
    {
    
    
        for(b=divisor.begin();b!=divisor.end();b++)
        {
    
    
            for(c=divisor.begin();c!=divisor.end();c++)
            {
    
    
                if((*a)*(*b)*(*c)==n)
                    count++;
            }
        }
    }
    cout<<count<<endl;
    return 0;
}

15. Nine to decimal conversion

Problem Description
This question is a fill-in-the-blank question, you only need to calculate the result, and use the output statement in the code to output the filled result.

What is the decimal positive integer
(
2022
)
9
(2022)
9
​converted
to decimal?

AC code:

#include <iostream>
using namespace std;
int main()
{
    
    
  cout<<2+2*9+2*9*9*9;
  return 0;
}

16. Arithmetic prime sequence

Title Description
This question is a fill-in-the-blank question. You only need to calculate the result and use the output statement in the code to output the filled result.

2,3,5,7,11,13,… is a sequence of prime numbers. similar:

7, 37, 67, 97, 127, 157 Such an arithmetic sequence composed entirely of prime numbers is called an arithmetic sequence of prime numbers.

The sequence above has a tolerance of 30 and a length of 6

In 2004, Green collaborated with Chinese Terence Tao to prove that there is an arithmetic sequence of prime numbers of any length. This is an amazing achievement in the field of number theory!

With this theory as a basis, please use the computer in your hand to search with confidence:

length is

What is the minimum tolerance value of the arithmetic prime sequence of 10?

AC code:

#include<bits/stdc++.h>
using namespace std;
bool judge(int x)
{
    
    
    for(int i=2;i<x;i++)
    {
    
    
        if(x%i==0)
            return false;
    }
    return true;
}
int main()
{
    
    
    int ans=1,num,d;
    for(int i=2;i<50000;i++)
    {
    
    
        if(judge(i))
        {
    
    
            for(int d=1;d<1000;d++)
            {
    
    
                for(int j=1;j<1000;j++)
                {
    
    
                    num=i+d*j;
                    if(judge(num))
                        ans++;
                    else
                    {
    
    
                        ans=1;
                        break;
                    }
                    if(ans==10)
                    {
    
    
                        cout<<d;
                        return 0;
                    }
                }
            }
        }
    }
}

17. Seven-segment code

Title Description
This question is a fill-in-the-blank question. You only need to calculate the result and use the output statement in the code to output the filled result.

Xiaolan wants to use a seven-segment digital tube to represent a special character. The figure above shows an illustration of the seven-segment digital tube. There are 7 LEDs
insert image description here
in the digital tube that can emit light, which are marked as

a,b,c,d,e,f,g。

Xiaolan needs to choose a part of diodes (at least one) to emit light to express characters. When designing the expression of characters, it is required that all light-emitting diodes be connected together.

For example:

b emits light, and other diodes do not emit light, which can be used to express a character.

For example

c light, other diodes do not light can be used to express a character. This scheme can be used to represent different characters than the scheme in the previous line, although it looks similar.

For example:

a,b,c,d,e glow,

f, g non-luminous can be used to express a character.

For example:

If b and f emit light, other diodes cannot be used to express a character if they do not emit light, because the light emitting diodes are not connected together.

Excuse me, how many different characters can Xiaolan express with the seven-segment digital tube?

AC code:

#include <iostream>
using namespace std;

int BackTrack(int graph[][7],int visit[],int n,int i){
    
    
  int count=1;
  for(int x=0;x<n;x++){
    
    
    if(visit[x]!=1&&graph[i][x]!=0){
    
    
      visit[x]=1;
      count+=BackTrack(graph,visit,n,x);
      visit[x]=0;
    }
  }
  return count;
}
int main()
{
    
    
  int graph[7][7]={
    
    
    {
    
    1,1,0,0,0,1,0},
    {
    
    1,1,1,0,0,0,1},
    {
    
    0,1,1,1,0,0,1},
    {
    
    0,0,1,1,1,0,0},
    {
    
    0,0,0,1,1,1,1},
    {
    
    1,0,0,0,1,1,1},
    {
    
    0,1,1,0,1,1,1}
  };
  int visit[7]={
    
    0};
  printf("%d",BackTrack(graph,visit,7,0)/2);
  return 0;
}

18. Jump

Title description
Xiaolan plays a game in a grid with
n
rows and m columns.

At the beginning, Xiaolan stood in the upper left corner of the grid, that is, row
1
1 and column
1
1 .

Xiaolan can walk on the grid chart. When walking, if he is currently at row
�r
and column
�c
, he cannot go to a row with a row number smaller than
�r smaller than �c At the same time, the straight-line distance he walks in one step does not exceed 3 3.




For example, if Xiaolan is currently at row 33, column
55 , he can go to row 33 , column 66, row 33 , column 77 , row 33, column 88 , Line 4 4, column 5 5, line 4 4, column 6 6, line 4 4, column 7 7, line 5 5, column 5 5 , line 5 5, column 6 6 , line 6 6 , line 5 One of 5 columns.






































Xiaolan will eventually go to row
�n
and column
�m

In the picture, some positions have rewards, which can be obtained by walking up, and some positions have punishments, which must be accepted by walking up. The reward and punishment are finally abstracted into a weight, the reward is positive, and the penalty is negative.

Xiaolan hopes that after going from row 11,
column 11 to row n m , the total weight sum is the largest. What is the maximum?






Input Description
The first line of input contains two integers � ,
� n ,m, denoting the size of the graph.


Next
� n
lines, each with
� m
integers, representing the weight of each point in the grid.

Among them,
1
� ≤
100 , 1 0 4 ≤weight 1 0 4 1≤n≤100, −10 4 ≤weight ≤10 4 .

















Output Description
Output an integer representing the maximum sum of weights.

Input and output example
Example 1
input

3 5
-4 -5 -10 -3 1
7 5 -9 3 -10
10 -2 6 -10 -4
copy
output

15

AC code:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    
    
    int n,m,trans;
    cin>>n>>m;
    int grapth[n+1][m+1];
    int x[9]={
    
    0,0,0,-1,-1,-1,-2,-2,-3};
    int y[9]={
    
    -1,-2,-3,0,-1,-2,-1,0};
    for(int i=1;i<=n;i++)
    {
    
    
        for(int j=1;j<=m;j++)
        {
    
    
            cin>>grapth[i][j];
            trans=INT_MIN;
            for(int t=0;t<9;t++)
            {
    
    
                if(i+x[t]>0&&j+y[t]>0)
                    trans=max(trans,grapth[i+x[t]][j+y[t]]);
            }
            if(trans!=INT_MIN)
                grapth[i][j]+=trans;
        }
        
    }
    cout<<grapth[n][m]<<endl;
}

19. Time display

Topic description
Xiaolan wants to cooperate with a friend to develop a website that displays time.

On the server, the friend has obtained the current time, represented by an integer, and the value is the number of milliseconds elapsed from 00:00:00 00:00:00 on November 11 , 1970 , 1970
to the current moment.










Now, Xiaolan wants to display this time on the client. Xiaolan does not need to display the year, month, and day, but only needs to display the hour, minute, and second, and does not need to display the millisecond, just discard it.

Given a time represented by an integer, please output the hours, minutes and seconds corresponding to this time.

Input Description
Input a line containing an integer representing time.

Output description
Output the current time represented by hours, minutes and seconds, in the format of HH:MM:SS, where HH represents hours, the value is
0
0​​​​ to
23
23​​​​, MM represents minutes, and the value is
0
0​​​ to
59
59​, SS means seconds, and the value is
0
0​ to
59
59​. When the hour, minute and second are less than two digits, the leading
0
0 is added.

Input and output example
Example 1
input

46800999
copy
output

13:00:00
copy
example 2
input

1618708103123
copy
output

01:08:23
copy
Evaluation case scale and agreement
For all evaluation cases, the given time is a positive integer not exceeding
1
0
18
10
18 .

AC code:

#include<iostream>
using namespace std;
int main()
{
    
    
    long long sum;
    cin>>sum;
    int hh,mm,ss;
    sum/=1000;
    hh=sum/60/60%24;
    mm=sum/60%60;
    ss=sum%60;
    printf("%02d:%02d:%02d",hh,mm,ss);
}

Guess you like

Origin blog.csdn.net/H1727548/article/details/131286572