627 - CS135501_I2P2014_mid1_practice_Captain_roger_on_wo Scoreboard

Time

2015/04/30 22:00:26 2015/04/30 22:00:26

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10158 2's complement
10159 GCD and LCM
10160 typewriter

10158 - 2's complement   

Description

 Transform the input x, into y bits 2’s complement.

The procedure of transforming an positive integer into its two’s complement is showed as follow:

Step1: transform the input into y-bits binary representation.

Step2: toggle each bits of the binary representation.

Step3: add 1 to the binary representation.

For example,

Input: 28 33

Step1: transform integer into binary representation, 28 -> 000000000000000000000000000011100

Step2: toggle each bits -> 111111111111111111111111111100011

Step3: add 1 -> 1111111111111111111111100100

So, the two’s complement representation of 28 is 111111111111111111111111111100100.

Example2:

Input: 10 34

Step1: transform integer into binary representation, 10 -> 0000000000000000000000000000001010

Step2: toggle each bits -> 1111111111111111111111111111110101

Step3: add 1 -> 1111111111111111111111111111110110

So, the two’s complement representation of 10 is 1111111111111111111111111111110110.

 

Don't forget to print a newline in the end.

Input

 Two positive integer x and y, where 0 < x < 2^32, and 32 < y < 100

Output

 Two’s complement of x

Sample Input  Download

Sample Output  Download

Tags




Discuss




10159 - GCD and LCM   

Description

Given two positive integer x and y, calculate the GCD (greatest common divisor) and LCM (least common multiple) of x and y.

 


Hint:

#include

int main()
{
        int x, y;
        scanf("%d %d", &x, &y);
        int xcp, ycp;
        int gcd;


        // x is not necessarily bigger than y
        xcp = x;
        ycp = y;
        while(xcp > 0 && ycp > 0){
                 /* calculate the gcd */
                 /* add your code here */
        }

        /* determine which one is gcd */
        /* add your code here */

        printf("GCD: %d\n", gcd);
        printf("LCM: %d\n", x*y/gcd);

        return 0;
}

 

Input

 Two positive integer x and y, where 0 < x,y < 10000.

Output

 GCD and LCM of x and y.

Sample Input  Download

Sample Output  Download

Tags




Discuss




10160 - typewriter   

Description

Long time ago, a writer should use a typewriter to print the letters on the paper, rather than on the screen. However, if any key on the typewriter is broken, the work will be suspended till the key is repaired. Your work is to design a program that can check which letter is used most and which letter is used least. Then, you can prepare a new key in advance to repair the broken one. In addition, we do not need to prepare the key for the letter that appears least because many other keys will break before it.

Input

A random string containing only letters (without digits).

They will be either upper case or lower case.

The length of input string will less than 50.

Output

Show the letter that appears most and least (in lower case) with how many times they appear.

Please follow the format of sample output.

If more than one letter counts the same times, print the previous one of the ahphabetical sequence.

Upper case or lower case of the same letter will be regarded as the same letter.

Sample Input  Download

Sample Output  Download

Tags




Discuss