1505 - I2P (I) 2018_Yang_hw1 Scoreboard

Time

2018/09/17 17:00:00 2018/10/01 15:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11111 Encode number
11112 Big Number
11576 Time conversion
11581 Push Push

11111 - Encode number   

Description

Suppose that we have an encoding scheme defined by the following mapping:
1->'A', 2->'B', 3->'C', ..., 9->'I'
Given a three-digit number N as the input, use the above mapping to encode N.

Input

A three-digit integer N

Output

The encoding result

Note that you do not need to print ‘\n’ at the end of the output.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11112 - Big Number   

Description

Replace the ??? in the following code so that the program can correctly compute
the square of the number entered by the user.
Assume that the input number is always an 8-digit positive integer.
* Note that the output format is always 16-digit wide with space prepended if needed.

For example, 
(11111111)^2 = _123456787654321
_ is a space character.


#include <stdio.h>
/* 2016/09/22 */
int first4(int x){
   return x/10000;
}
int last4(int x){
   /* The operator % in C computes the remainder after division.
      For example, the answer of 23%7 will be 2.*/
   return x%10000;
}
int first8(int x){
   return x/100000000;
}
int last8(int x){
   return x%100000000;
}
int shift4(int x){
   return x*10000;
}
int main(void){
   int x;
  int a, b;
  int c1, c2, c3;
  /* Assume that the input is always an 8-digit positive integer. */
  scanf("%d", ???); 
  a = first4(x);
  b = last4(x)
  c3 = ???;
  c2 = ???;
  c1 = ???;
  printf("%4d%08d%04d", ???, ???, ???);  
  /* %04d will display a 4-digit number and add 0 as padding before the number if necessary */
  return 0;
}

[Hint]
Assume that the input 8-digit integer x can be expressed by a*10000 + b .
The square of x can be expressed as a*a*100000000 + 2*a*b*10000 + b*b .
We may partition the computation into three parts.
An illustration of the idea is as follows:
 
| 4 digits | 4 digits | 4 digits | 4 digits |
                             |        b * b            |
              |      2 * a * b         |
|        a * a            |
|    c1      |          c2              |    c3     |
 
※要注意進位的情形!!

Input

The input is always an 8-digit positive integer

Output

the square of input .

Note that you do not need to print ‘\n’ at the end of the output.

Sample Input  Download

Sample Output  Download

Tags




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




11581 - Push Push   

Description

There are 2 positive integers A and B.

B is the number of pushing all digits of A right by 1 digit.

e.g. A = 5678, B = 8567

Please calculate the sum of A and B

 

Input

A is a 4-digit number

Output

A + B

Sample Input  Download

Sample Output  Download

Tags




Discuss