Description
Koro Sensei, the homeroom teacher of Class 3-E was prepared a list of new students that is sent to assasinate him. Tadaomi has to sort the names in alphabetical order make sure that the 10 Million Yen Bounty goes to the right person.
Help Tadaomi program a name list.
Note that :
1. Upper case letter has higher priority than lowercase letter. (E.g. Kill > kill)
2. If there is a string with the same substring, the shorter string has higher priority. (E.g. assasination > assasinationtime)
You can use the following code :
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char string[100001][105];
int cmp(const void *a,const void *b){
/* write your code here */
}
int main(){
int i = 0;
while(scanf("%s", string[i]) != EOF) i++;
qsort(/* fill in this blank */);
for(int j = 0; j < i; j++) printf("%s\n", string[j]);
}
Input
Input consists of several lines L, each of them is a string
0<L<100000
Length of string won't exceed 100
Output
Print out the strings in alphabetical order, one string per line
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Olip the cat felt that cat life is too boring. So she wants to be a fish.
She asked RH the green sock for help.
But RH is busy with his data analysis homework, so if Olip wants his help, Olip help him write his homework.
His homework requires him to find the longest binary distance of an integer. The binary distance is the number of zeros "0" between two adjoining ones "1" in the binary representation of an integer.
For example, the binary representation of 37 is 100101, so 37 has two binary distances which are 2 and 1. And the longest binary distance is 2.
If there is no "0"s between two adjoining "1"s, the binary distance will be 0. e.g. 7 (111), has two binary distances = 0.
If the number of "1" in the binary representation is less than 2, the binary distance will be -1. e.g. 8 (1000) only has one binary distances = -1.
Input
First line is the number of testcases t 1 ≤ t ≤ 20)
Then, t lines follow
Each line contains one integer N (0 ≤ N ≤ 263 - 1).
Output
Output contains q lines and each line contain the longest binary distance of the input integer ended with '\n'.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
RH the greeen sock likes to count.
He wants to find the minimum flips required in 3 positive integers x,y,z. Such that (X OR Y == Z), a bitwise OR operation.
The flip operation is the change of a single bit "1" to "0", or the change of bit "0" to "1" in binary representation.
E.g.
x = 0010 --> x = 0001
y = 0110 --> y = 0100
------------- ------------
z = 0101 z = 0101
Input
Input is three positive integers, x, y, z.
0 < x,y,z < 109
Output
Output is minimum number of flips to make x OR y == z
Don't forget to include "\n"