1372 - CS I2P (II) 2017-2 Lee Final Practice Scoreboard

Time

2017/12/29 13:20:00 2018/01/15 00:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

10478 - Simply Fractions   

Description

Given several fractions, compute their sum and express the answer in the simplest fraction form.

Input

There are many test cases in one subtask.

The first line of each test case contains an integer t, which indicates the number of fractions in the input. Each of the following t lines contains two integers a and b, which represent the numerator and the denominator of a fraction.

subtask 1 : t=2. 1<=a,b<=10.
subtask 2 : t<=5. 1<=a,b<=10.
subtask 3 : t<=5. 1<=a,b<=50.
subtask 4 : t<=10. 1<=a,b<=100.

Output

Each test case outputs one line.

The output is the sum reduced to the simplest fraction form. You need to print a '/' between the numerator and the denominator.

Sample Input  Download

Sample Output  Download

Tags

qq 哈雷路亞 ........ ???? 為何一直錯QQ 找不到錯的地方R There are many test 0.0 這好好玩 可以這樣喔 陳冠儒到此一遊 煥宗好帥!!



Discuss




11029 - extend   

Description

Given an integer sequence, say {6, 1, 4, 3, 5, 2}, we can choose any pair of two neighboring numbers (in a circular sense) and swap them to generate a new sequence. For example,

If we choose 6 and 2, we get {2, 1, 4, 3, 5, 6} after swapping.
If we choose 1 and 4, we get {6, 4, 1, 3, 5, 2} after swapping.

Try to generate all possible results for the original sequence, and print the results in lexicographical order. For the example above, the output would be

1 6 4 3 5 2
2 1 4 3 5 6
6 1 3 4 5 2
6 1 4 3 2 5
6 1 4 5 3 2
6 4 1 3 5 2

Hint:
1. Use the set and vector containers.
2. The items in a set will be automatically sorted in lexicographical order.

main

Input

An integer sequence, separated by spaces. End by EOF.

Output

List all possible results for the original sequence in lexicographical order.

Each line contains one sequence, where there is a space between each number.

 Note that there is a '\n' at the end of each line.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11055 - Vector Intersection   

Description

Given two vectors of numbers, output their intersection set.

Note: the numbers of vectors need not to be unique.

Input

There are multiple test cases. Each case contains four lines. The first line begins with an integer N. The second line contains N integers, representing the numbers in the first set. The third line has one integer M, and the fourth line contains M integers, represent the numbers in the second set. All the numbers are 32 bit signed integers. The input is terminated if N = 0.

For case 1, 1 <= N, M <= 103
For case 2, 1 <= N, M <= 104
For case 3, 1 <= N, M <= 105
For case 4, 1 <= N, M <= 106

Output

For each test case, print the intersection of the two sets. Output them in ascending order. If the intersection of the two sets is an empty set, print “empty” (without quotes).

 

Note: There's a newline character at the end of each output.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11447 - Use std::map   

Description

This problem will help you understand how to use std::map.

http://en.cppreference.com/w/cpp/container/map

Notice, this time, first and last is [first, last].

目前有五個測資,第三筆測資不算,答題測資看另外四筆

Input

The input consist of series of command. Each commands is insert, range output or range erase.

insert: inserts a string (cmd) with the key (key) to map. If the key has already existed, insert the cmd at the begining of string (the string which the key belongs).

For example,

insert 0 "abc"

insert 1 "def"

the map should contain "abc", "def".

insert 0 "xyz"

the map should contain "xyzabc", "def".

 

range output: outputs the string from key (first) to key (last). Output a space character (' ') after printing an element.

 

range erase: erase the string from key (first) to key (last).

 

operator<<: outputs all strings in map. From the smallest key to biggest key. Output a space character (' ') after printing an element.

Output

Complete insert, output, erase and operator<<.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11447.cpp

Partial Judge Header

11447.h

Tags




Discuss




11460 - string exam   

Description

Write a program that will reverse the order of words in each sequence of sentences while preserve the order of letters.

If the first character of word is vowel, add "ay" in the end position of the word.

Input

The input file will consist of several lines of several words. Words are contiguous stretches of printable characters delimited by a white space.

 

Output

The output will consist of the same lines and words as the input file. However, the order of words will be reversed.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11460.cpp

Partial Judge Header

11460.h

Tags




Discuss




11461 - Copy a vector (Implement a vector 7)   

Description

You must follow the rules as below:

1. do not use any static variables

2. do not use any variables which is not inside a function

3. only new, operator new, delete and operator delete are allowed to allocate or deallocate memory

4. memory usage limit: 16384 byte

You are required to implement a vector.

You have to enable C++11 in this problem. (e.g. "g++ -std=c++11 ...")

Input

There are seven functions in Vector that you have to implement, the functionality is as below:

  • default constructor: initializes pointers. Do not allocate memory.
  • copy constructor: copys the elements of rhs. The new capacity is rhs.size().
  • copy assignment operator: copys the elements of rhs. The new capacity is max(capacity(), rhs.size()).
  • erase: erases a element at pos.
  • insert: inserts a val at pos. When capacity is not enough, the new capacity is max(old capacity + 1, old capacity * 3).
  • reserve: reserves storage (Increase the capacity of the container to a value that's equal to new capacity. If new capacity is greater than the current capacity, new storage is allocated, otherwise the method does nothing.).
  • destructor

Output

Complete a Vector (default constructor, copy constructor, copy assignment operator, erase, insert, reserve and destructor).

Sample Input  Download

Sample Output  Download

Partial Judge Code

11461.cpp

Partial Judge Header

11461.h

Tags




Discuss




11484 - Draw the Shapes   

Description

Giving basic information of some shapes, you need to draw them on the Cartesian coordinate system and calculate the total area.

PI has already defined in function.h.

Input

There are only 2 shapes in this problem : 

1. R (Rectangle), followed by 4 points. Each point represent 1 vertex of the rectangle, with the format (x, y).

2. C (Circle), followed by 1 point represent the centre of the circle, and a number of its radius.

If the radius is negative, set it to 0.

e.g., the result of sample input would be like :

Output

Output the total area of all the shapes.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11484.cpp

Partial Judge Header

11484.h

Tags




Discuss




11485 - Use std::set   

Description

This problem will help you understand how to use std::set and comparator.

e.g., std::set<std::vector<int>>

http://en.cppreference.com/w/cpp/container/set

Input

How to compare the integer sequence (calculate the key of an integer sequence):

  • get the length of integer sequence (size)
  • key value=[first element]*(size)+[second element]*(size-1)+[third element]*(size-2)+...+[last element]*1
  • compare the key value. Small key value is smaller.
  • if the length of a integer sequence is 0, the key value is 0.
  • e.g., the key of an integer sequence "3 9 -1 3 -6" is 48 (3*5+9*4+(-1)*3+3*2+(-6)*1)

 

The input consist of series of command. Each commands is insert, range_out or output.

​insert: inserts an integer sequence (each value is greater than -6 and smaller than 11, stop reading from cin when value is 0). If the key has already existed, then

  • output "exist\n"
  • erase the integer sequence from set
  • reverse the integer sequence (from input)
  • insert the reversed integer sequence

For example,

insert 3 9 -1 3 -6 0

The set should contain 3 9 -1 3 -6.

insert 9 -2 6 6 0

The set should contain 6 6 -2 9.


range_out: outputs all integer sequences from the integer sequence (first key) to the integer sequence (second key) of set (including the second key). First key and second key are read from input (each value is greater than -6 and smaller than 11, stop reading from cin when value is 0).

For example,

insert 2 -5 -5 0

insert 3 9 -1 3 -6 0

insert 7 6 1 2 0

insert 10 10 10 2 0

range_out -5 0 10 9 2 0

It should output

3 9 -1 3 -6

7 6 1 2

For example,

insert 2 -5 -5 0

insert 3 9 -1 3 -6 0

insert 7 6 1 2 0

insert 10 10 10 2 0

range_out -5 0 10 10 10 0

It should output

3 9 -1 3 -6

7 6 1 2

 

output: outputs all integer sequences from the smallest key to the biggest key of set. Output a space character (' ') after printing an integer. Output a newline character ('\n') after printing all elements of a key.

Output

Complete insert, range output and output.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11486 - Josephus Prob. using Circular Linked List (better)   

Description

In computer science and mathematics, the Josephus problem (or Josephus permutation) is a theoretical problem related to a certain counting-out game.

People are standing in a circle waiting to be executed. Counting begins at a specified point in the circle and proceeds around the circle in a specified direction. After a specified number of people are skipped, the next person is executed. The procedure is repeated with the remaining people, starting with the next person, going in the same direction and skipping the same number of people, until only one person remains, and is freed.

The problem — given the number of people, starting point, direction, and number to be skipped — is to choose the position in the initial circle to avoid execution.

You're asked to solve this problem using circular linked list.

Input

The input has two positive integers, n (the number of people) and m (kill every mth people).

Output

The output is the order of people that were killed.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11486.c

Partial Judge Header

11486.h

Tags




Discuss




11719 - Implement a list 6 (operator new)   

Description

You must follow the rules as below:

1. do not use any static variables

2. do not use any variables which is not inside a function

3. only new, operator new, delete and operator delete are allowed to allocate or deallocate memory

4. memory usage limit: 16384 byte

You are required to implement a list.

You have to enable C++11 in this problem. (e.g. "g++ -std=c++11 ...")

If you don't know what operator new is, check 11419 - Using your vector​.

Input

The input consist of a number of operations. Each operations (copy ctor, copy assign, back, front, clear, erase, insert and show) are separated by a newline character ('\n').

Operation copy ctor: following by a non-negative integer (which list calls the copy constructor).

Operation copy assign: following by a non-negative integer (which list calls the copy assignment operator).

Operation back: Print the value of last node.

Operation front: Print the value of first node.

Operation clear: Erase all nodes.

Operation erase: following by a non-negative integer (erase position). Erase a node at erase position.

Operation insert: following by a non-negative integer (insert position) and a string. Insert a node at insert position with inserted string.

Operation show: print the value of all nodes in the list. Print a whitespace character (' ') after printing the value of nodes. If the list is empty, do not print anything.

Output

Implement List (constructor, copy constructor, copy assignment operator, destructor, back, front, clear, erase and insert) and operator<<(std::ostream &os,const List &lst).

Sample Input  Download

Sample Output  Download

Partial Judge Code

11719.cpp

Partial Judge Header

11719.h

Tags




Discuss