| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 12495 | Hailstone Numbers |
|
| 12496 | Eight Queen |
|
Description
We are provided with a number N. Our task is to generate all the Hailstone Numbers from N and find the number of steps taken by N to reduce to 1.
Collatz Conjecture: A problem posed by L. Collatz in 1937, also called the 3x+1 mapping, 3n+1 problem. Let N be a integer. According to Collatz conjecture, if we keep iterating N as following
N = N / 2 // For Even N
and N = 3 * N + 1 // For Odd N
the result of N will eventually converge to 1 irrespective of the choice of N
There have an example below :
Input : N = 7
Output :
Hailstone Numbers: 7, 22, 11, 34, 17,
52, 26, 13, 40, 20,
10, 5, 16, 8, 4, 2,
1
No. of steps Required: 17
Hint:
int n;
while(scanf("%d", &n) != EOF){
// your implement code
}
Input
N_1
N_2
...
N_i the input number ( 2 <= N_i < 10^4)
Output
Output Hailstone Numbers (the seqence generated by Collatz conjecture)
(each element sperates with one space and make sure there is a trailing space followed by a newline character at the end of each line.)
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Each chessboard has numbers written on each square and is supplied with 8 chess queens. The task is to place the 8 queens on the chessboard in such a way that no queen threatens another one, and so that the sum of the numbers on the squares selected is the minimum. (For those unfamiliar with the rules of chess, this implies that each row and column of the board contains exactly one queen, and each diagonal contains no more than one queen.)
Write a program that will read in the number and details of the chessboards and determine the lowest scores possible for each board under these conditions.
Input
Input will consist of K (the number of boards), on a line by itself, followed by K sets of 64 numbers, each set consisting of eight lines of eight numbers. Each number will be a non-negative integer less than 10000. Each case is separated by a blank line. There will never be more than 20 boards.
Output
The outputs of all test cases should be printed in order. For each test case a line, print the lowest score.