| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10739 | Binary addition |
|
| 11186 | Pascal's triangle |
|
| 11592 | Change the Cap |
|
| 11857 | Another Spiral |
|
Description
Problem Description
Given a positive integer N, transform it to its unsigned binary representation (e.g. 10 => 1010). Your program needs to output the binary representation of N+1 and the number of carries during the addition in binary representation.
For example, if the input is 11 (in decimal), your program needs to output 1100, because it is the binary representation of 11+1=12. Also your program needs to output 2, because during the binary addition of 11+1, there are two carries generated.
1011 (11 in binary)
+ 0001 (1 in binary)
---------------------------------
1100 (12 in binary)
Input
The input consist of an integer N (0 <= N <= 1024)
Output
The binary representation of N+1 and the number of carries during the binary addition of N+1. Those two numbers are separated by a space. Note that you do not need to print ‘\n’ at the end of the output.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
As described in Wikipedia, Pascal's triangle is a triangular array of the binomial coefficients. The element k on row n of Pascal’s triangle can be calculated by the following relation:
C(n, 1) = 1, for n = 1, 2, …
C(n, n) = 1, for n = 1, 2, …
C(n, k) = C(n-1, k-1) + C(n-1, k), for k = 2, 3, … and for n = 2, 3, …
Given a nonnegative integer M, display the Pascal’s triangle from row 1 to row M.
Use '%10d' to print each element. Print a newline '\n ' at the end of each row.
(Note that the sample output print only 1 blank within each element, which is wrong. You should use '%10d'.)
Input
A positive integer M (1<=M<=30)
Output
Print the Pascal triangle from level 1 to level M.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Johnson, a pro table tennis player, is a member of school team in NTHU. The coach trains the whole team three times a week. After training, Johnson needs to drink a lot of sports drinks named "Fin & Bubblegum" (also known as "F&B").
One day, the company decides to hold a long-term promotion. After you collect three caps from the bottle, you can return them back to the company and get a new bottle of "F&B".
Johnson notices that he needs to drink N bottle of "F&B" every week. He would like to know the minimum number of "F&B" he needs to buy every week.
If you can solve this problem, maybe Johnson will teach you how to play table tennis.
For this problem, you don't need to calculate the remaining caps from last week.
Attention : Johnson found out that some programs may give him wrong answer in some other cases, so he decided to add more testcases to ensure the correctness of your program. (rejudge in 10/5 18:20)
Input
There is only one integer for each testcase.
1 <= N <= 104
Output
Please output the minimum number of "F&B" Johnson needs to buy every week.
Remember to print '\n' after your answer.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
In this problem, you are asked to output a sequence of integer number (i.e. 0, 1, 2, 3 ......) in the "spiral form".
A square is an area with NxN grids. You put the first number (i.e. 0) in the position according to the input. Then, you put the next number to the right (or left) of the previous one, and you will reach the right (or left) border of the square. Any time you can't find an empty place on current direction, you turn "right" (or "left") and place the next number until your direction is opposite to origin direction which you reach this grid.
Sample IO shows four testcases, your input has only four integer and output N*N number.
Input
There are four integer numbers for the input. The first number N (1<= N <= 20) denotes the size of the edges of the square. The second number decides the direction of this case (0 means clockwise, and 1 means anticlockwise). The third and forth number mean the initial position in which row and column.
Output
Print the content in the square. There should be N lines in the output.
If the gird is not reached, the content should be 0. (note: the content of initial position is also 0)
note: print a space before each number, and print '\n' in the end of each line.