<> Final of the 12th Blue Bridge Cup software competition C/C++ university C group

Overall , This time there are both difficult and easy questions, which is still quite uniform . However, the pure prime number didn't run out and surprised himself .
Finally, I got on the last bus of the second prize, hahaha , Make up for last year's regret , Satisfied .ƪ(˘⌣˘)┐

The last game of the University ended happily ~

<> test questions A: Integer range

Total score of this question :5 branch
【 Problem description 】
use 8 Bit binary ( One byte ) To represent a nonnegative integer , The minimum value represented is 0, be
What is the maximum value that can be expressed in general ?
【 Answer submission 】
This is a question to fill in the blanks , You just need to calculate the results and submit them . The result of this question is one
Integer , Only fill in this integer when submitting the answer , If you fill in extra content, you will not be able to score .

255

<> test questions B: bandwidth

Total score of this question :5 branch
【 Problem description 】
What is the network bandwidth of Xiaolan family 200 Mbps, Excuse me? , Using Xiaolan's network is theoretically the most convenient every second
How much can I download from the Internet MB Content of .
【 Answer submission 】
This is a question to fill in the blanks , You just need to calculate the results and submit them . The result of this question is one
Integer , Only fill in this integer when submitting the answer , If you fill in extra content, you will not be able to score .

20

<> test questions C: Pure prime number

Total score of this question :10 branch
【 Problem description 】
If a positive integer has only 1 And itself , Is called a prime number ( Also known as prime ).
The first few prime numbers are :2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, ···.
If all decimal places of a prime number are prime numbers , We call it a pure prime number . for example :2,
3, 5, 7, 23, 37 Are pure prime numbers , and 11, 13, 17, 19, 29, 31 Not a prime number . of course 1, 4, 35
Nor is it a pure prime number .
Excuse me? , stay 1 reach 20210605 in , How many prime numbers are there ?
【 Answer submission 】
This is a question to fill in the blanks , You just need to calculate the results and submit them . The result of this question is one
Integer , Only fill in this integer when submitting the answer , If you fill in extra content, you will not be able to score .

answer :1903

The problem didn't work out at that time , After that, I found a fatal habit problem of my own , I didn't add optimization conditions when judging prime numbers
i*i<=n, I'm afraid I don't want to jump into the West Lake . I was surprised by my IQ , It's hard not to do a simple problem .

<> code :
#include<bits/stdc++.h> using namespace std; int check(int n){ for(int i=2;i*i
<=n;i++){ if(n%i==0){ return 0; } } return 1; } int check2(int n){ while(n){ int
k=n%10; if(check(k)==0 ||k==1 ||k==0){ return 0; } n=n/10; } return 1; } int
main(){ long long ans=0; for(int i=1;i <= 20210605 ;i++){ if(check2(i) && check(
i)){ ans++; } } cout<<ans<<endl; return 0; }
<> test questions D: Full date

Total score of this question :10 branch
【 Problem description 】
If the sum of the numbers in a date is a complete square , It is called a perfect day
stage .
for example :2021 year 6 month 5 The sum of the figures of the day is 2 + 0 + 2 + 1 + 6 + 5 = 16, and
16 Is a perfect square number , It is 4 Square of . therefore 2021 year 6 month 5 Day is a full date .
for example :2021 year 6 month 23 The sum of the figures of the day is 2 + 0 + 2 + 1 + 6 + 2 + 3 = 16,
Is a perfect square number . therefore 2021 year 6 month 23 Day is also a full date .
Excuse me? , from 2001 year 1 month 1 Day arrives 2021 year 12 month 31 Japan China , How many complete days are there
stage ?
【 Answer submission 】
This is a question to fill in the blanks , You just need to calculate the results and submit them . The result of this question is one
Integer , Only fill in this integer when submitting the answer , If you fill in extra content, you will not be able to score .

977

<> code ( Direct violence ):
#include<bits/stdc++.h> #include<iostream> using namespace std; int year(int n)
{ if((n%4==0&&n%100!=0) || (n%400==0)){ return 29; } else{ return 28; } } int
quzhen(int n){ int sum=0; while(n){ int k=n%10; sum+=k; n=n/10; } return sum; }
int check(int n){ int k=sqrt(n); if(k*k==n){ return 1; } return 0; } int main(){
int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; int ans=0; for(int i=2001;i
<=2021;i++){ for(int j=1;j<=12;j++){ day[2]=year(i); for(int z=1;z<=day[j];z++){
int a=quzhen(i)+quzhen(j)+quzhen(z); cout<<i<<" "<<j<<" "<<z<<" "<<a<<" "<<check
(a)<<endl; if(check(a)){ ans++; } } } } cout<<ans<<endl; return 0; } //977
<> test questions E: Minimum weight

Total score of this question :15 branch
【 Problem description 】
For a rooted binary tree T, Xiaolan defines the weights of nodes in this tree W(T) as follows :
The weight of the empty subtree is 0.
If a node v Left subtree L, Right subtree R, Respectively C(L) and C® Nodes , be
W(v) = 1 + 2W(L) + 3W® + (C(L)) 2 C®.
The weight of the tree is defined as the weight of the root node of the tree .
Xiaolan wants to know , For a tree with 2021 Binary tree with two nodes , The minimum weight of the tree may be multiple
less ?
【 Answer submission 】
The result of this question is to fill in the blank , You just need to calculate the results and submit them . The result of this question is one
Integer , Only fill in this integer when submitting the answer , If you fill in extra content, you will not be able to score .

It really won't -_-, Blind guess full binary tree , No time. Just fill in one .

<> test questions F: Capitalize

time limit : 1.0s Memory limit : 256.0MB Total score of this question :15 branch
【 Problem description 】
Give a string that contains only uppercase and lowercase letters , Please put all lowercase letters in it
Convert to uppercase letters and output the string .
【 Input format 】
The input line contains a string .
【 Output format 】
Output string converted to uppercase .
【 sample input 1】
LanQiao
【 sample output 1】
LANQIAO
【 Scale and agreement of evaluation cases 】
For all profiling cases , The length of the string does not exceed 100.

<> code :
#include<bits/stdc++.h> #include<iostream> using namespace std; int main(){
string s; while(cin>>s){ int len=s.length(); for(int i=0;i<len;i++){ if(s[i]>=
'a'&&s[i]<='z'){ s[i]=s[i]-'a'+'A'; } } cout<<s<<endl; } return 0; }
<> test questions G: 123

time limit : 1.0s Memory limit : 256.0MB Total score of this question :20 branch
【 Problem description 】
Xiaolan found an interesting sequence , The first few items of this series are as follows :
1, 1, 2, 1, 2, 3, 1, 2, 3, 4, …
Xiaolan found , Before this sequence 1 Item is an integer 1, next 2 Item is an integer 1 to 2, next
3 Item is an integer 1 to 3, next 4 Item is an integer 1 to 4, And so on .
Xiaolan wants to know , In this sequence , What is the sum of successive segments .
【 Input format 】
The first line of input contains an integer T, Indicates the number of queries .
next T that 's ok , Each line contains a set of queries , Among them i The row contains two integers l i and r i , express
The second in the query sequence l i Number to r i Sum of numbers .
【 Output format 】
output T that 's ok , Each line contains an integer representing the answer to the corresponding question .

<>【 sample input 】

3
1 1
1 3
5 8

<>【 sample output 】

1
4
8

【 Scale and agreement of evaluation cases 】
about 10% Evaluation cases for ,1 ≤ T ≤ 30, 1 ≤ l i ≤ r i ≤ 100.
about 20% Evaluation cases for ,1 ≤ T ≤ 100, 1 ≤ l i ≤ r i ≤ 1000.
about 40% Evaluation cases for ,1 ≤ T ≤ 1000, 1 ≤ l i ≤ r i ≤ 10 6 .
about 70% Evaluation cases for ,1 ≤ T ≤ 10000, 1 ≤ l i ≤ r i ≤ 10 9 .
about 80% Evaluation cases for ,1 ≤ T ≤ 1000, 1 ≤ l i ≤ r i ≤ 10 12 .
about 90% Evaluation cases for ,1 ≤ T ≤ 10000, 1 ≤ l i ≤ r i ≤ 10 12 .
For all profiling cases ,1 ≤ T ≤ 100000, 1 ≤ l i ≤ r i ≤ 10 12 .

Humble violence cheat points >_<

<> code :
#include<bits/stdc++.h> #include<iostream> using namespace std; int t; long
long a,b; long long s[1000000]; int main(){ while(cin>>t){ while(t--){ cin>>a>>b
; int k=1,j=0; long long sum=0; for(int i=1;i<=b;i++){ j++; if(j>k){ k++; j=1; }
//cout<<j<<endl; if(i>=a){ sum+=j; } } cout<<sum<<endl; } } return 0; }
<> test questions H: XOR transformation

time limit : 1.0s Memory limit : 256.0MB Total score of this question :20 branch
【 Problem description 】
Xiaolan has one 01 strand s = s 1 s 2 s 3 ··· s n .
Every moment in the future , Xiaolan wants to be right about this 01 The string is transformed once . The rules for each transformation are the same .
about 01 strand s = s 1 s 2 s 3 ··· s n , Transformed 01 strand s ′ = s ′
1 s′2 s′3 ··· s′n by :s ′1= s 1 ;s ′i= s i−1 ⊕ s i .
among a ⊕ b Represents the XOR of two binary , When a and b The result is 0, When a and b
At different times, the result is 1.
Excuse me? , after t After secondary transformation 01 What is a string ?
【 Input format 】
The first line of input contains two integers n, t, Respectively represent 01 The length of the string and the number of transformations .
The second line contains a length of n of 01 strand .
【 Output format 】
The output line contains a 01 strand , Is the transformed string .

<>【 sample input 】

5 3
10110

<>【 sample output 】

11010

【 Example description 】
Initially 10110, Transform 1 Change to 11101, Transform 2 Change to 10011, Transform 3
Change to 11010.

【 Scale and agreement of evaluation cases 】
about 40% Evaluation cases for ,1 ≤ n ≤ 100, 1 ≤ t ≤ 1000.
about 80% Evaluation cases for ,1 ≤ n ≤ 1000, 1 ≤ t ≤ 10 9 .
For all profiling cases ,1 ≤ n ≤ 10000, 1 ≤ t ≤ 10 18 .

It started with violence , Later, it is found that each string transformation has a cycle period, so it is optimized . Find out the bad cycle first , Then take a remainder . Should be able to mix some points ~

<> code :
#include<bits/stdc++.h> #include<iostream> using namespace std; long long n,t;
string str; string s; string check(string s2){ for(int i=1;i<n;i++){ if(s2[i]==s
[i-1]){ s2[i]='0'; } else{ s2[i]='1'; } } return s2; } int main(){ int p=0;
while(cin>>n>>t){ cin>>s; p=0; map<string,int>mp; map<int,string>mp2; for(int i=
1;i<=t;i++){ str=check(s); if(mp[str]==0){ mp[str]=i; mp2[i]=str; } else{ p=i;
break; } s=str; //cout<<i<<" "<<s<<endl; } if(p==0){ cout<<s<<endl; } else{ int
h=(p-mp[str]); p=t%h; //cout<<p<<" "<<(p-mp[str])<<endl; if(p==0){ p=h; } cout<<
mp2[p]<<endl; } } return 0; } /* 5 9 10110 */
<> test questions I: Chocolates

time limit : 1.0s Memory limit : 256.0MB Total score of this question :25 branch
【 Problem description 】
Xiaolan likes chocolate very much , He eats a piece of chocolate every day .
One day Xiaolan went to the supermarket to buy some chocolate . There are many kinds of chocolate on supermarket shelves , Every trick
Acrylic has its own price , Quantity and remaining shelf life days , Xiaolan only eats chocolate that has not expired ,
How much does Xiaolan spend at least to buy for himself to eat x Heaven's chocolate .
【 Input format 】
The first line of input contains two integers x,n, It indicates the number of days to eat chocolate and the number of days to eat chocolate
Number of species .
next n Line describes the chocolate on the shelf , Among them i The row contains three integers a i ,b i ,c i , express
The first i The unit price of each kind of chocolate is a i , Shelf life remaining b i day ( From now on b i Days can eat ), number
Quantity c i .
【 Output format 】
Output an integer indicating the minimum cost of Xiaolan . If it doesn't exist, let Xiaolan eat it x Day purchase plan ,
output −1.

<>【 sample input 】

10 3
1 6 5
2 7 3
3 10 10

<>【 sample output 】

18

<> test questions I: Chocolates

Final of the 12th Blue Bridge Cup software competition C/C++ university C group
【 Example description 】
One of the best options is the second 1 Planting and buying 5 block , The first 2 Planting and buying 2 block , The first 3 Planting and buying 3 block . front 5 day
Eat first 1 species , The first 6,7 Day eating day 2 species , The first 8 to 10 Day eating day 3 species .
【 Scale and agreement of evaluation cases 】
about 30% Evaluation cases for ,n, x ≤ 1000.
For all profiling cases ,1 ≤ n, x ≤ 100000,1 ≤ a i ,b i ,c i ≤ 10 9 .

After looking at this question, I feel that dp, Why can't we write ~

<> code :

Technology
©2019-2020 Toolsou All rights reserved,
C++ of string of compare usage Python Study notes ( one )evo Tool usage problems ——Degenerate covariance rank, Umeyama alignment is not possibleRISC-V_GD32VF103-TIMER0 timer interrupt java Array subscript variable _Java Basic grammar : array be based on stm32 Control four-wheel trolley motor drive ( one ) be based on redis Design of liking function Software engineering career planning mysql Query random data by conditions _MySQL Random query of several qualified records centos7 install RabbitMq