# | Problem | Pass Rate (passed user / total user) |
---|---|---|
10993 | Polynomial class |
|
13161 | Kuo Sends Names To Mars |
|
13163 | KYてぇてぇ — Birthday Present(class) |
|
13443 | Recursive Acronym |
|
Description
Create a class Polynomial. The internal representation of a Polynomial is an array of terms. Each term contains a coefficient and an exponent, e.g., the term 2x4 has the coefficient 2 and the exponent 4.
- Use a 51-element array, coefficients, of digits to store each coefficient.
- Use a integer variable, greatestPower, to store an exponent.
Provide public member functions that perform each of the following tasks:
- Adding two Polynomial.
- Subtracting two Polynomial.
- Multiplying two Polynomial.
- Printing coefficients of the Polynomial in descending order.
Note:
1. This problem involves three files.
- function.h: Class definition of Polynomial.
- function.cpp: Member-function definitions of Polynomial.
- main.cpp: A driver program to test your class implementation.
You will be provided with main.cpp, and asked to implement function.h and function.cpp.
function.h
main.cpp
2. For OJ submission:
Step 1. Submit only your function.cpp into the submission block.
(***Note that you don’t need to submit your function.h.)
Step 2. Check the results and debug your program if necessary.
Input
There are four lines.
The first two lines represent the greatest power and the corresponding coefficients of the first polynomial.
The last two lines represent the greatest power and the corresponding coefficients of the second polynomial.
Note that the coefficients are in descending order and each element is separated by a blank.
Output
Your program should print the coefficients of the sum, difference and product of these two polynomials in descending order, respectively.
Note that every answer should be followed by a new line character.
Sample Input Download
Sample Output Download
Partial Judge Code
10993.cppPartial Judge Header
10993.hTags
Discuss
Description
Kuo-chan can help send names to Mars.
However, he hates palindromes of length greater than 1. He gets upset whenever receiving a name containing palindrome substrings of length greater than 1.
We call a name's substring a palindrome if and only if it reads the same backwards and forwards. A string a is a substring of a string b if a can be obtained from b by deleting several (possibly zero or all) characters from the beginning and several (possibly zero or all) characters from the end.
For example,
- "bcd" and "e" are substrings of "abcde" but "ace" and "bz" are not.
- "abccba", "aba", and "ee" are palindromes but "abcd" and "abcabc" are not.
Yang-chan also wants to send his name to Mars. However, as Kuo-chan's best friend, he doesn't want to upset Kuo-chan.
Therefore, Yang-chan will modify his name by replacing a letter at any position with any English letter. He can use this operation arbitrarily many times (possibly zero).
Yang-chan wants to know how many letters have to be modified at least?
(Please use C++ to solve this problem.)
Input
The first and only line of the input contains a non-empty string S of lowercase English letters — Yang-chan's name.
The length of S will not exceed 105.
Output
You should output a single integer, meaning the number of letters Yang-chan has to modify at least to avoid upsetting Kuo-chan.
Remember to add new line in the end
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Kuo-chan is given a sequence A and a constant K as his birthday present from Yang-chan.
Kuo-chan is allowed to perfrom the following operation:
- push x — push x to the end of A
- pop — remove the median value of A (the median value of A is A[ (|A|+1)/2 ])
- programming tanoshi — for 1 <= i <= |A|, assign A[ i ] % K to A[ i ]
For example, if A = [4, 3, 5], K = 2
push 11 ► A = [4, 3, 5, 11]
pop ► A = [4, 5, 11]
pop ► A = [4, 11]
programming tanoshi ► A = [0, 1]
Yang-chan is curious about what A is after Kuo-chan performs some operations to it.
Help him find it out!
Input
The first line contains three integers N K Q — the length of A, the constant Yang-chan gives Kuo-chan, the number of operations Kuo-chan performs.
The second line contains N integers a1, a2, ..., aN (1 <= ai <= N) — the elements of A.
Each of the next Q lines describes the operations. Each line is one of three types:
- push x (1 <= x <= N)
- pop
- programming tanoshi
Different testcases have different constraints.
- N <= 103, Q <= N, K <= N, operations: {pop}
- N <= 103, Q <= 2N, K <= N, operations: {pop, push}
- N <= 103, Q <= 2N, K <= N, operations: {pop, push, programming tanoshi}
- N <= 105, Q <= N, K <= N, operations: {pop}
- N <= 105, Q <= 2N, K <= N, operations: {pop, push}
- N <= 105, Q <= 2N, K <= N, operations: {pop, push, programming tanoshi}
Output
You should print one line containing the elements of A after the operations. For 1 <= i <= |A|, the i-th number should be A[ i ].
Sample Input Download
Sample Output Download
Partial Judge Code
13163.cppPartial Judge Header
13163.hTags
Discuss
Description
A recursive acronym is an acronym (an abbreviation word formed from the first letter of words) that refer to itselft recursively. For instance, GNU stands for GNU not Unix.
In the community of computer science, there exists somewhat a tradition that quite a few people tend to choose such recursive acronym to express their humorousness, e.g. ATI stands for ATI Technology Incoperated (a graphic card manufacturer which was acquired by AMD and became Radeon later), TikZ stands for TikZ ist kein Zeichenprogramm (German; TikZ is not a drawing program, TikZ is a LaTeX package to draw vector graphics), and so forth.
In this problem, your task is to determine whether some words can form a typical recursive acronym refering to the first word.
Note
This problem is case-insensitive, i.e., it does not matter that a letter is lower case or upper case.
You could call getline()
to get entire content including spaces of a line until the newline character, and use stringstream
to split the line by spaces. For more detail, you may refer to online resources.
Input
Each test case may contain several lines. For each line, please determine whether it can form a typical recursive acronym refering to its first word or not.
The number of lines won't exceed 10. Each line won't contain more than 1000 words. The length of words won't exceed 1000.
Output
For each line, if it can form a typical recursive acronym refering to its first word, then print o'_'o, otherwise QQ. Remember to put a newline character.