| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11445 | Copy a vector (Implement a vector 6) |
|
| 12715 | BigInt++ |
|
| 12722 | Fibonacci Machine |
|
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: 9216 byte
You are required to implement a vector.
If you don't know what is an operator new, you can check 11419 - Using your vector.
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 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
11445.cppPartial Judge Header
11445.hTags
Discuss
Description
"int" is too small to store large numbers!
That's why you decided to implement your own data type, BigInt.
You need to implement 7 basic functions:
1. Constructor. It is initalized by a string representing a non-negative integer without leading zeroes (despite "0" itself).
2. Destructor.
3,4,5,6. ++x, x++, --x, x--, as in the C/C++ standard.
7: char* to_s(): returns a duplicate of the number in char*, e.g., "123".
UPDATE:
Note that you don't need to implement negative numbers. When the number is 0 and you have to decrement it, you can ignore the operation.
Input
The first line contains an integer T, representing the number of testcases that follow.
For each testcase, a non-negative integer less than pow(10, 1023) is given in the first line.
An integer Q follows, representing the number of operations regarding the testcase.
Q lines follow, each in the form of "B++", "++B", "B--", or "--B", the effect of which is the same as specified in the C/C++ standard.
Output
For each operation, print the result in one line, without leading zeroes.
Sample Input Download
Sample Output Download
Partial Judge Code
12715.cppPartial Judge Header
12715.hTags
Discuss
Description
You need to implement the following functions for the class Fib:
void setBase(int, int);
int64_t operator[](int);
After setBase(x, y), the data structure, fib, should contain an infinite length sequence, { x, y, x + y, x + 2y, 2x + 3y, ... } and so on. Every term is the sum of the two terms before it, except for the first two terms.
Of course you won't be able to store an infinite length sequence, but you need to manage to respond with the k'th term of the sequence whenever fib[k] is invoked.
Input
Q
OP_1
OP_2
...
OP_Q
Where Q is an integer representing the number of operations. Q lines follow.
OP_i is the i'th operation, and it may be one of the two following forms:
0 A B
1 K
Where "0 A B" will invoke fib.setBase(A, B), and "1 K" will invoke fib[K]. Note that the index is 0-based. The operations has to be accomplished in the order they are given.
1 <= Q <= 10^6
0 <= A, B <= 10^9
0 <= K <= 10^9
It is guaranteed that the result always fits in 64 bit signed integer.
It it guaranteed that the first operation always starts with "0".
Output
For every operation that starts with "1", print the result in one line.