| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10335 | Compute Parity |
|
| 10367 | Decimal to Hexadecimal |
|
| 10370 | Insider Stock Trading |
|
| 10375 | Palindromic String |
|
Description
The parity of a binary word is 1 if the number of 1s in the word is odd; otherwise, it is 0. For example, the parity of 1011 is 1, and the parity of 10001000 is 0. Parity checks are used to detect single bit errors in data storage and communication. It is fairly straightforward to write code that computes the parity of a single 32-bit integer.
Compute the parity of a 32-bit integer?
Input
Each line of the input contains a non-negative 32-bit integer x. Input file is terminated by end of file.
Output
For each line of input you will have to produce one line of output which contains the parity of x.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
In the decimal system, the position of a digit is used to signify the power of 10 that digit is to be multiplied with. For example, “314” denotes the number 3 × 100 + 1 × 10 + 4 × 1. Similarily, in the hexadecimal system, the position of a digit is used to signify the power of 16 that digit is to be multiplied with; therefore, “314” denotes the number 3 × 162 + 1 × 16 + 4 × 1.
Write a function that performs base conversion from decimal to hexadecimal. Specifically, the input is an integer, representing a decimal number; the output is a string representing the input in the hexadecimal system. Note that we use “A” to represent 10, “B” for 11, . . . , and “F” for 15 in the hexadecimal system.
Input
Each line of the input contains an integer x, representing a decimal number. Input file is terminated by end of file.
Output
For each line of input you will have to produce one line of output which is the hexadecimal representation of x.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
The cost of a stock on each day is given in an array, find the max profit that you can make by buy and sell only once in those days. For example, if the given array is <180, 260, 310, 40, 695>, the maximum profit can earned by buying on day 3, selling on day 4; the profit is 655.
Input
Each line of the input contains a series of positive integers seperating by one white space, representing the prices of a stock. Input file is terminated by end of file.
Output
For each line of input you will have to produce one line of output which is the maximum of profit you can gain if you can buy and sell stock only once.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
define a palindromic string to be a string which when all the nonalphanumeric are removed it reads the same front to back ignoring case. For example, “A man, a plan, a canal, Panama.” and “Able was I, ere I saw Elba!” are palindromic, but “Ray a Ray” is not.
Input
Each line of the input contains a string. Input file is terminated by end of file.
Output
For each line of input you will have to produce one line of output. "true" if the input is a palindromic string; "false" otherwise.