1518 - I2P (I) 2018_Chen_hw2 Scoreboard

Time

2018/10/02 00:00:00 2018/10/11 15:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11119 binary addition
11576 Time conversion
11592 Change the Cap

11119 - binary addition   

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 <= 1022)

Output

The "unsigned" 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

11119



Discuss




11576 - Time conversion   

Description

Please convert 24-h time format to 12-h time format .


Hint1:

You can define an integer called 'flag' to indicate a.m. or p.m.
And then you can use 'flag' to compute the key information : 'a' , 'p'
int key_info = 'a' * ((flag+1)%2) + 'p' * flag ; 
key_info will be 'p' when flag is 1 , and be 'a' when flag is 0.

Hint2:

Note that 1200 belongs to p.m. 
Namely, the output should be 00:00 p.m.

and 0000 belongs to a.m.

Namely, the output should be 00:00 a.m.

Input

always a 4-digit integer

Output

  hour    +   ":"   +  minute  +  "whitespace"  +  "a.m." / "p.m."
(2-digit)                (2-digit)

hour and minute numbers need to have 0 prepended if needded.

Note that there is no need to add "\n" at the end of output.

Sample Input  Download

Sample Output  Download

Tags

#11576



Discuss




11592 - Change the Cap   

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

hi peko so oil la HACHAAMA konpeko



Discuss