| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10372 | 補考problem1 |
|
| 10373 | 補考problem2 |
|
| 10374 | Lab11 |
|
Description
The input contains two polynomials f(x) and g(x).
f(x) = amxm + a(m-1)x(m-1) + ⋯ + a1x1 + a0x0
g(x) = bnxn + b(n-1)x(n-1) + ⋯ + b1x1 + b0x0
where m,n∈N, 0≤m,n≤10.
Compute h(x) = f(x)g(x).
Note that all the coefficients are integers.
Input
m
am a(m-1) … a1 a0
n
bn b(n-1) … b1 b0
Note that the coefficients are separated by a blank.
Output
The coefficients of h(x) in descending power order.
Use "%d " to print each coefficient and there is a newline at the end.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
The input contains three integers of the same length (same number of digits).
For example,
3412
5232
9128
For each integer, we rearrange its digits from small to large and produce a new integer. Therefore, the three integers above become
1234
2235
1289
The output shows the three integers in an increasing order, that is,
1234
1289
2235
You may use the following piece of code:
/* Using bubble sort to rearrange an array A[n] */
for (i = 0; i < n; i++) {
for (j = 1; j < n; j++) {
if (A[j-1] > A[j]) {
/* swap A[j-1] A[j] */
}
}
}
Input
The length of three integers, 1 ≤ length ≤ 9.
Three integers of the same length.
Output
Three rearranged integers in an increasing order.
Print a newline at the end of each integer.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Given a list of English names, use ‘qsort’ to sort the names in lexicographic order. The number of names is less than or equal to 10, and each length of the name is no more than 5.
The detailed rules of sorting are:
1. Sort the strings in alphabetical order. E.g. “abc” is prior to “abd”.
2. The string with smaller length has top priority. E.g. “xyz” is prior to “ABCD”.
3. The uppercase alphabet is prior to lowercase alphabet. E.g. “AA” is prior to “aA”.
You may use the following piece of code:
#include#include #include #define SIZE 10 #define LENGTH 6 int compare_str_ptr(const void *a, const void *b) { /* your code here */ } int main() { char strs[SIZE][LENGTH] = {0}; char *ptrs[SIZE]; int i, N; scanf("%d", &N); for (i=0; i Input
Number of names
Name 1
Name 2
Name 3
…
Output
Print the sorted names line by line. Each line contains one name and ends with a newline character.
Sample Input Download
Sample Output Download
Tags
Discuss