## There are five questions in total, with average difficulty.

catalogue

Beat the drum and pass the flowers

## Number of eligible

Title Description:

give N and k. Find a positive integer that is not less than N and satisfy that there are The k-digit number is 3, and as small as possible.

Input format:

One line, two integers N (1 < = n < = 10 ^ 9) and k(1 ≤ k ≤ 6).

Output format:

Output a number to indicate the answer.

Input and output examples:

Input:

2333334 6

Output:

3033333

Solution: read n and k; Large loop: i start from n and enumerate upward; Small loop: get the single digit of this number each time; If it is 3, the counter increases by 1; Remove its single digit; If you find the answer, jump out of the loop and output.

#include <cstdio> #include <algorithm> #include<iostream> using namespace std; int main() { int i, k, n; scanf("%d%d", &n, &k); for (i = n; ; i++) { int tmp = i, sum = 0; while (tmp != 0) { if(tmp % 10 == 3) sum++; tmp /= 10; } if(sum == k) break; } cout << i; return 0; }

## Elected representative

Title Description:

The College of communication and intelligence ran for student representative and won N (1 ≤ n ≤ 20000) nomination votes, each of which is written with a student number (from 1 to 100 Integer). It is now required to sort out the candidates according to the nomination votes. Arrange these nomination votes in order, only keep the position where the student number appears for the first time, and delete the other positions of the same student number. Then output these student numbers. Is simply to solve the problem.

Input format:

The input contains two lines:

The first line contains a positive integer n, indicating the number of nomination votes;

The second line contains n An integer separated by a space. Each integer is the student number in the nomination ticket.

Output format:

The output has only one line. The non repeated numbers are output in the order of input, and the integers are separated by a space.

Input and output examples:

Input:

5 10 12 93 12 75

Output:

10 12 93 75

Solution: use the vis array to record whether a number has appeared. After reading n, cycle n times. Read in a number; • If it doesn't appear, output it and set it to appear. If it appears, skip.

#include <iostream> using namespace std; bool vis[105];//Record whether the number entered has appeared int main() { int a, n; cin >> n; for(int i = 1; i <= n; i ++) { cin >> a; if(!vis[a]) { cout << a << " "; vis[a] = 1; } } return 0; }

## Achievement statistics

Title Description:

The "Java programming" class of the College of communication and intelligence has N(1 ≤ 100) Students who know their personal information and grades:

- Name (no longer than) two thousand and twenty (string of lowercase letters only)
- Usual score (00 to 100) (integer of)
- Final exam scores (0 to 100) (integer of)

Because the final exam is a little difficult, in order to make the score less ugly, the final exam score is adjusted. The final score after adjustment is multiplied by the root sign 10, then round up.

Finally, the student's total score is 60% of the final test score, plus 40% of the usual score, rounded to the nearest whole number.

Please rank the results of these students.

Input format:

The first line is an integer N.

next N lines, each line includes a string and two integers, separated by spaces. The sub table represents the student's name, usual score and final exam score.

Output format:

Output the name and total score of the corresponding students from high to low. If the scores of two students are the same, the one with the first input order should also be the first in the output.

Input and output examples:

Input:

4 a 60 36 b 70 49 c 50 25 d 60 36

Output:

b 70 a 60 d 60 c 50

Problem solving: structure, and the use of custom sorting. After reading the information, sort it using sort.

#include <algorithm> #include<iostream> #include<cmath> using namespace std; struct stu { string name; int id, score; } s[110]; bool cmp(stu &x, stu &y) { if (x.score == y.score) return x.id < y.id; else return x.score > y.score; } int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int mid, final; cin >> s[i].name >> mid >> final; s[i].id = i; s[i].score = int(round(0.6 * ceil(10 * sqrt(final)) + 0.4 * mid)); } sort(s, s + n, cmp); for (int i = 0; i < n; i++) { cout << s[i].name << ' ' << s[i].score<< endl; } return 0; }

## Recite the answer

Title Description:

The final exam of "Java programming" in the College of communication and intelligence comes from a selection library, with a total of n Each question consists of a question and an answer, which is a string to ensure that all questions are different from each other. This question bank has been sent to students for preparation.

In the formal examination, the test paper contains q questions, each of which has 4 options you need from 4 Choose the one that matches the answer. Please finish the exam.

Input format:

Two positive integers in the first line n, q.

Next n lines, 2 per line A space delimited string representing the question and answer to the question.

next q lines, 5 per line A string of characters separated by spaces. The first string represents the exam question, and the rest The four strings are the ABCD options of this topic to ensure that the options are different.

Output format:

For each question in the exam, output A or B or C or D to represent the options corresponding to the answer to this question, separated by line breaks to ensure that all questions are solved.

Input and output examples:

Input:

8 5 kqet qyf kxyhfcbfy sorlawygdg igklkkzmet lh ijlvjtwirf osfumbui iict mdz tcdsczbopw yccknz fun emdg rsdsv tawdpyb kqet pvc kfd uehtepa qyf kxyhfcbfy ebrlaftges ehfe sorlawygdg kokdukzg igklkkzmet veqiwikpr yohdgdpb lh nu kqet eb jnf qyf qkf iict ycleqorhek mda mdz ahgou

Output:

D C C C C

Problem solving: use string array to record each question and corresponding answer in the question bank. Read in the question and four options during the exam. Then find the question bank from the beginning. After finding the question, compare the answer with each option in turn. If it is consistent, the number of the corresponding option is output.

#include<iostream> #include<string> using namespace std; struct A { string x,y; }; A a[50000]; struct B { string a,b,c,d,e; }; B b[5000]; int n,q; int main() { cin>>n>>q; for(int i=1;i<=n;i++) cin>>a[i].x>>a[i].y; for(int i=1;i<=q;i++) cin>>b[i].a>>b[i].b>>b[i].c>>b[i].d>>b[i].e; for(int i=1;i<=q;i++) for(int j=1;j<=n;j++) { if(b[i].a==a[j].x) { if(b[i].b==a[j].y) cout<<"A"<<endl; if(b[i].c==a[j].y) cout<<"B"<<endl; if(b[i].d==a[j].y) cout<<"C"<<endl; if(b[i].e==a[j].y) cout<<"D"<<endl; } } return 0; }

## Beat the drum and pass the flowers

Title Description:

Collective activities are organized by the College of communication and intelligence N students are arranged in a circle and numbered 0 to n-1.

If a student has flowers in his hand, he can pass the flowers to the third student in a larger direction (or start counting from 0 again) K classmates. If No If i have a flower in my hand, the flower will be passed to the next second (i + k) in the hands of classmate mod n.

Now there are m students have flowers in their hands. The numbers are p_i. With the passage of time, some students got flowers, but some didn't get flowers all the time. How many students will never get flowers.

Input format:

First line, three positive integers n. M, K represents the number of people, the number of flowers and the step size.

Second line, m A nonnegative integer p_1,p_2,....p_m means which students have the flowers in their hands at the beginning.

Output format:

A total of one line, an integer, represents the answer.

Input and output examples:

Example 1:

Input:

4 2 2 0 1

Output:

0

Example 2:

Input:

4 2 2 0 2

Output:

2

Solution: use an array to indicate whether it has been accessed. a[i] indicates whether the ith student has visited. Read one position at a time and jump straight ahead. This position is t, and the next is (t+k)%n. Mark the skipped position until it touches the skipped position.

#include<bits/stdc++.h> using namespace std; #define ll long long #define N 1000010 int n, m, k, t, a[N], ans; int main() { cin >> n >> m >> k; for(int i = 0; i < m; i++) { cin >> t; if(a[t]) continue; while(1) { if(a[t] == 1) break; a[t] = 1; t += k; t %= n; } } for(int i = 0; i < n; i++) { if(a[i] == 0) ans++; } cout << ans; return 0; }