Remaining Candy Count
Problem Description
Little Red has n candies, and she wants to distribute them evenly among her m good friends. To ensure fairness, each friend must receive the same number of candies, and any leftover candies will be kept by Little Red (which could also be zero).
Can you help her write a program to calculate how many candies Little Red will have left after distributing them?
Input
Input two positive integers n and m, representing the total number of candies Little Red has and the number of friends (Little Red herself is not included in m).
Output
Output a single line with an integer indicating the number of candies Little Red has left.
Sample InputCopy
10 3
Sample OutputCopy
1
Hint
0≤n,m≤1000
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m;
cin>>n>>m; //n candies for m people
cout<<n%m; //remaining candies
}
Height of the Tree in Month N
Problem Description
Little Ming planted a magical tree that grows taller every month according to the following rules: In the first month, the tree grows a fixed height of 10 centimeters, and thereafter, it grows 2 centimeters more than the previous month (for example: in the second month, it grows 12 centimeters, in the third month, it grows 14 centimeters, etc.).
Please calculate the final height of the tree in the n-th month.
Input
The first line contains two integers n and h, representing the total number of months n and the initial height of the tree h.
Output
Output an integer indicating the final height of the tree.
Sample InputCopy
3 12
Sample OutputCopy
48
Hint
1≤n≤100, 0≤h≤100
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,h;
cin>>n>>h; //n months, initial height h
int x=10; //In the first month, it grows 10cm
for(int i=1;i<=n;i++){
h+=x; //current month grows x cm
x+=2; //grows 2 cm more than the previous month
}
cout<<h;
}
Exam Paper Grading
Problem Description
The busy teacher needs to grade the programming exam that took place yesterday. The teacher received n submitted papers. The grading rules for each paper’s score are as follows:
If the score is 100, output “SSS”;
If the score is greater than or equal to 90 but less than 100, output “S”;
If the score is greater than or equal to 80 but less than 90, output “A”;
If the score is greater than or equal to 70 but less than 80, output “B”;
If the score is greater than or equal to 60 but less than 70, output “C”;
For any other score, output “F” (without quotes).
Input
The first line contains an integer n, indicating the total number of papers to be graded; the second line contains n integers ai, representing the scores of each paper, separated by spaces.
Output
Output n lines of strings, indicating the grading results for the n papers.
Sample InputCopy
5
50 60 70 80 90
Sample OutputCopy
F
C
B
A
S
Hint
1≤i≤n, 0≤ai≤100, 1≤n≤100
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
int x;
cin>>x; //input score
//grading from high to low
if(x==100) cout<<"SSS"<<endl;
else if(x>=90) cout<<"S"<<endl;
else if(x>=80) cout<<"A"<<endl;
else if(x>=70) cout<<"B"<<endl;
else if(x>=60) cout<<"C"<<endl;
else cout<<"F"<<endl;
}
}
Lucky Number 7
Problem Description
Little Ming believes that some numbers bring good luck, which he calls “lucky numbers”. The characteristics of lucky numbers are:
1. The sum of the digits of the number is divisible by 7
2. The last digit is 7
Please find out how many lucky numbers exist between 1 and n.
Input
An integer n, indicating the range for finding lucky numbers from 1 to n (inclusive).
Output
Output an integer indicating the count of “lucky numbers”.
Sample InputCopy
30
Sample OutputCopy
1
Hint
1≤n≤10^5
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,ans=0;
cin>>n;
//start from 7 and increase by 10 each time to ensure the last digit is 7 for efficiency
for(int i=7;i<=n;i+=10){
int x=i,s=0;
while(x){
s+=x%10;
x/=10;
}
if(s%7==0) ans++;
}
cout<<ans;
}
Replace ABC
Problem Description
There is a string S of length n, where each character in the string is one of ‘A’, ‘B’, or ‘C’. You can perform a series of operations on the string, specifically:
(1) In odd-numbered operations (e.g., 1st, 3rd, ...), you can choose any contiguous substring "ABC" in the string and replace it with "B" (i.e., compressing three characters into one character).
(2) In even-numbered operations (e.g., 2nd, 4th, ...), you can choose any contiguous substring "ABC" in the string and replace it with "AC" (i.e., compressing three characters into two characters).
How many operations can you perform at most?
Input
The first line contains a positive integer n; the second line contains a string S of length n.
Output
Output a single line indicating the number of operations performed according to the problem requirements.
Sample InputCopy
6
AABCCC
Sample OutputCopy
2
Hint
1≤n≤2*10^5
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main() {
int n;
string s;
cin>>n>>s;
int count = 0; // number of operations
// Traverse the string sequentially, perform operations when "ABC" is found
for (int i=0; i<s.size()-2; i++) {
// Check for "ABC" substring
if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') {
// Determine if the current operation is odd or even
if ((count + 1) % 2 == 1) { // odd operation
s.replace(i, 3, "B");
// Backtrack, the new B may combine with previous A, and prevent out of bounds
i = max(-1, i-2);
} else { // even operation
s.replace(i, 3, "AC");
}
count++;
}
}
cout << count << endl;
return 0;
}
If children encounter problems during the process or want to participate in programming competition training, they can add VX. We have rich experience in various competitions, focusing on competition planning to ensure that every child does not fall behind in their programming journey!
2025 Information Literacy Competition – Algorithm Creative Practice Challenge C++ Junior High Group Re-examination Questions
2025-09-04

16th Blue Bridge Cup C++ Programming Intermediate Provincial Competition Questions
2025-09-01

16th Blue Bridge Cup Python Intermediate Group Provincial Competition Questions
2025-08-31

16th Blue Bridge Cup Python Intermediate Group National Competition Questions
2025-08-30
