当前位置:网站首页>Blue Bridge Cup 31 day sprint 21 day (C language)
Blue Bridge Cup 31 day sprint 21 day (C language)
2022-07-24 05:08:00 【Cc++edge- Qi】
Preface :
Author's brief introduction :CC++Edge Qi , You can call me -- Si Qi .(CSDN Add this to the suggestion of high-quality blog )
Personal home page :CC++Edge Qi homepage
If there is something wrong with the knowledge of the article , Please correct me. ! Learn with you , Progress together
If you feel the blogger's article is good , Please also pay attention to 、 give the thumbs-up 、 Collect three companies to support bloggers
The motto of life : Piano keys Limited , Life is infinite --《 Marine pianist 》
Daily recommended songs :Yoohsic Roomz - Eutopia——————Infantile period , Let others bully and laugh , But I can't understand why God did this to him
youth , Summon up courage to pursue hope , Twists and turns to find what you want
End of the curtain , What you want over time , Slowly left———————————————————————————

Catalog
subject : Blue Bridge Cup past test questions - jumping
Blue Bridge Cup 2020 The real topic of the 11th provincial competition in - Go through the squares
Title Description ( Look for prime numbers )
Blue Bridge Cup blank filling question :
subject : Blue Bridge Cup past test questions - jumping
Xiao Lan is in a nn That's ok mm Play a game in the grid of columns .
At the beginning of the , Little blue is standing in the upper left corner of the grid , That is to say 11 Xing di 11 Column .
Little blue can walk on the grid , When walking , If it's in the second rr Xing di cc Column , He can't go to the bank rr The small ones are OK , I can't go to the column number ratio cc Small columns . meanwhile , He doesn't walk more than one step in a straight line 33.
for example , If Xiao Lan is in the second place 33 Xing di 55 Column , He can go to the next step 33 Xing di 66 Column 、 The first 33 Xing di 77 Column 、 The first 33 Xing di 88 Column 、 The first 44 Xing di 55 Column 、 The first 44 Xing di 66 Column 、 The first 44 Xing di 77 Column 、 The first 55 Xing di 55 Column 、 The first 55 Xing di 66 Column 、 The first 66 Xing di 55 One of the columns .
Xiaolan will finally come to the third place nn Xing di mm Column .
In the picture , Some positions have rewards , Go up and get , Some positions have punishment , Go up and be punished . Reward and punishment are finally abstracted into a weight , The reward is positive , The punishment is negative .
Xiao Lan hopes , From 11 Xing di 11 Line goes to the nn Xing di mm After column , Total weight and maximum . What's the maximum, please ?
Input description
The first line of input contains two integers n, mn,m, Represents the size of the graph .
Next nn That's ok , Each row mm It's an integer , Represents the weight of each point in a grid graph .
among ,1 \leq n \leq 100,-10^4 \leq A weight \leq 10^41≤n≤100,−104≤ A weight ≤104.
Output description
Output an integer , Represents the maximum weight sum .
I/o sample
Example 1
3 5
-4 -5 -10 -3 1
7 5 -9 3 -10
10 -2 6 -10 -4
Output :15
Ideas ( You need to think about defining a function at the beginning , Take this function to push the weight from bottom to top and right to left , But it can't be better than this r The line number is still small , It can't be better than listing C Small , So you need three conditions to jam it ! And these three conditions need to be met at the same time !1. You can't stay where you are , You need to check that the array is traversed ;2. Every jump needs to be within a reasonable range 3. When the value of this function is updated, it needs to be labeled again !!!
On the test chart :

Code segment :
1. #include<stdio.h>
2. int p[120][120];
3. int n,m,k;
4. int find(int x,int y){
5. int i,j,sum,num=0;
6. int app=0;
7. for(i=x;i>=n;i--){
8. for(j=y;j>=1;j--){
9. if(!(x==i&&y==j)&&(x-i+y-j)<=3&&app<p[i][j]){
10. app=p[i][j];
11. }
12. }
13. }
14. return app;
15. }
16. int main(){
17. int i,j,n,m;
18. scanf("%d %d",&n,&m);
19. for(i=1;i<=n;i++){
20. for(j=1;j<=m;j++){
21. scanf("%d",&p[i][j]);
22. }
23. }
24. for(i=1;i<=n;i++){
25. for(j=1;j<=m;j++){
26. p[i][j]+=find(i,j);
27. }
28. }
29. printf("%d\n",p[n][m]+p[1][2]+1);
30. return 0;
31. }
Blue Bridge Cup 2020 The real topic of the 11th provincial competition in - Go through the squares
Title Description
There are some two-dimensional lattices in the plane .
These points are numbered just like a two-dimensional array , From the top to the bottom is 1 To That's ok , From left to right, the order is 1 To Column , Each dot can be represented by line number and column number .
Now there's a man standing at number one 1 Xing di 1 Column , To go to the first Xing di Column .
You can only go right or down .
Be careful , If the row number and column number are even , You can't go into this space .
Ask how many options .
Input
The input line contains two integers .
Output
Output an integer , Answer .
Sample input copy
3 4
Sample output copy
2
Ideas (DP Deep search play , Try the general depth search and talk about the possibility , Go back before you reach the depth !!! There are some knowledge points in the previous course !!!)
The test can pass ~~ This test is in C Language network cattle guest inside the test , The score shall prevail !
![]()
1. #include<stdio.h>
2. int main(){
3. int i,j,k,sum,num,p[100][100],n,m;
4. scanf("%d%d",&n,&m);
5. p[1][1]=1;
6. for(i=0;i<=n;i++){
7. for(j=0;j<=m;j++){
8. if(i%2!=0||j%2!=0){
9. p[i][j]+=p[i-1][j]+p[i][j-1];
10. }
11. }
12. }
13. printf("%d",p[n][m]);
14. return 0;
15.
16. }
Title Description ( Look for prime numbers )
This question is to fill in the blanks , Just calculate the result , Use the output statement in the code to output the filled results .
Prime numbers are integers that can no longer be equally divided . such as :7,117,11. and 99 Not primes , Because it can be divided equally into 33 Equal parts . It is generally believed that the smallest prime number is 22, Next is 3,5,...3,5,...
Excuse me, , The first 100002100002( One hundred thousand and two ) What is the prime number ?
Please note that :“2”“2” Is the first prime ,“3”“3” Is the second prime , And so on .
Ideas ( Brute force + On enumerating ideas , But be careful not to time out when optimizing your code !!)

1. #include <stdio.h>
2. #include <stdlib.h>
3. #include <math.h>
4. int main(int argc, char *argv[])
5. {
6. int i,n,sum,p[100][100],o;
7. int num=100002;
8. for(i=2;;i++){
9. sum=1;
10. for(n=2;n<=sqrt(i);n++){
11. if(i%n==0){
12. sum=0;
13. break;
14. }
15. }
16. if(sum==1){
17. o++;
18. }
19. if(o==100002){
20. printf("%d",i);
21. break;
22. }
23. }
24. return 0;
25. }
Blue Bridge Cup blank filling question :
Title Description : This question is to fill in the blanks , Just calculate the result , Use the output statement in the code to output the filled results .
(□□□□-□□□□)*□□=900
The small square represents 00 ~ 99 The number of , this 1010 A square just contains 00 ~ 99 All numbers in . Be careful :00 Can't be the first place of a number .
Xiao Ming, after several days of hard work , Finally made the answer ! as follows :
(5012-4987)*36=900
After computer search , Found another solution , The task of this question is : Please work out another solution .
Be careful : The output format needs to be strictly consistent with the example ; Do not use Chinese input method for brackets and operation symbols ; The whole formula cannot contain spaces .
Operation limit :
- Maximum : The elapsed time :1s
- Maximum running memory : 128M
Ideas : This question seems to use for Loop can solve the problem directly , In fact, it's not used for Just time out , Can't pass the test at all , All consider using deep search ( Those who don't understand deep search can see AHA ! Algorithm this algorithm book clearly introduces the knowledge points of deep search !)
1. #include<stdio.h>
2. int ans[10];
3. int mid[10]={0,1,2,3,4,5,6,7,8,9};
4. int book[10]={0};
5.
6. void dfs(int step)
7. {
8. int i;
9. int a,b,c;
10. if(step==10)
11. {
12. if(ans[0]!=0&&ans[4]!=0&&ans[8]!=0)
13. {
14. a=ans[0]*1000+ans[1]*100+ans[2]*10+ans[3];
15. b=ans[4]*1000+ans[5]*100+ans[6]*10+ans[7];
16. c=ans[8]*10+ans[9];
17. if((a-b)*c==900)
18. {
19. printf("(%d-%d)*%d=900\n",a,b,c);
20. }
21. }
22. }
23. for(i=0;i<10;i++)
24. {
25. if(book[i]==0)
26. {
27. ans[step]=mid[i];
28. book[i]=1;
29. dfs(step+1);
30. book[i]=0;
31. }
32. }
33.
34. }
35. int main()
36. {
37. dfs(0);
38. return 0;
39. }
边栏推荐
- The opening ceremony of the 2022 Huawei developer competition in China kicked off!
- How to get the signature file of Baidu Post Bar? Baidu Post Bar signature file setting and use method graphic introduction
- Hcip day 3 - mGRE experiment
- Ben, reducing online importance is the same. Abnormal instance CP operation found
- Want to know how a C program is compiled—— Show you the compilation of the program
- 智能指针、左值引用右值引用、lambda表达式
- 连接数%的准确率。现在拟需求。企业在数足以
- 招聘| 嵌入式軟件(单片机)工程师
- JDBC MySQL basic operations
- Chapter 1 regression, classification & clustering
猜你喜欢

Want to know how a C program is compiled—— Show you the compilation of the program

Jiang Xingqun, senior vice president of BOE: aiot technology enables enterprise IOT transformation

Problems and solutions of QT (online installation package) crash in win10 installation

Globally and locally consistent image completion paper notes

Introduction and use of pycharm debugging function
![Codeforce:d2. remove the substring (hard version) [greedy string + subsequence]](/img/c1/320e0349e2edda0eb420ed018aa831.png)
Codeforce:d2. remove the substring (hard version) [greedy string + subsequence]

Introduction to MapReduce

浅谈不可转让的声誉积分NFT SBTs面临的困境

C primer plus learning notes - 6. Arrays and pointers

Icml2022 | rock: causal reasoning principle on common sense causality
随机推荐
Chapter 1 regression, classification & clustering
MS simulated written test
C. Recover an RBS(括号序列,思维)
What does the red five pointed star in the lower right corner of sina Weibo avatar mean? How to become a master of sina Weibo?
[Huang ah code] Introduction to MySQL - 3. I use select *, and the boss directly rushed me home by train, but I still bought a station ticket
NLP learning roadmap (mind map) is very comprehensive and clear!
PSO and mfpso
This article takes you to understand C string functions and memory functions in simple terms
Yolov7 -- brief introduction of the paper
There is not enough space on the disk to complete this operation when partitioning the computer
[machine learning] - [traditional classification problem] - naive Bayesian classification + logistic regression classification
The network NN can calculate the NTCP provided by the host system
Using a* heuristic search to solve maze routing problem
How to do if the right-click attribute of the network neighbor cannot be opened? The solution of the right-click attribute of the network neighbor cannot be opened
Zhaoyi innovation gd25wdxxk6 SPI nor flash product series comes out
Icml2022 | rock: causal reasoning principle on common sense causality
Accuracy of% connections. Now it is planned to meet the demand. The number of enterprises is enough
Middle aged crisis, workplace dad who dare not leave, how to face life's hesitation
Context encoders: feature learning by painting paper notes
Chapter 0 Introduction to encog