# | Problem | Pass Rate (passed user / total user) |
---|---|---|
11112 | Big Number |
|
13552 | Easy math problems |
|
13989 | Roommate's Alarm Clock |
|
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;
}
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.
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
Description
Patrick is going to hand in his math homework tomorrow. He left his homework undone and played outside all day with Squidward. It’s now 3 am and Patrick doesn’t know how to finish these problems at all since he never studies. Therefore, he comes to you, the smartest person he knows, and hopes you can solve all of the problems in his homework book.
The problems are easy: given a math expression containing two numbers and an operator. Calculate the result rounded to 3rd decimal places.
For example, the answer of 12.1 + 7 is 19.100, and the answer of 7 / 3 is 2.333.
Patrick will bring you a Krabby Patty if you successfully answer all questions.
Input
Given a math expression containing two numbers x, y and a char c (‘+’, ‘-’, ‘*’ or ‘/’) seperating the numbers.
(-1000 ≤ x, y ≤ 1000)
Output
Output the answer, which is a floating point rounded to 3rd decimal places.
Please print '\n' at the end of the line.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Hank's roommate, Noah, sets an alarm clock every day, but the alarm only wakes up Hank and cannot wake up Noah.
This annoys Hank. Now, given Hank's bedtime and the alarm set by Noah, please help Hank calculate how much sleep he can get in total for one day. ( This means Hank won't sleep for more than a day. )
( Note :
In the first sample test case, Hank slept from 23:59 today to 00:34 the next day.
In the third sample test case, Hank fell asleep at the same time the alarm went off, so Hank didn't sleep at all. )
Input
There are two lines of input.
The first line is in the format h1:m1, representing Hank's bedtime.
The second line is in the format h2:m2, representing the alarm set by Noah.
You can assume that h1, m1, h2, and m2 are all 2-digit integers.
(Note: you can use scanf("%d:%d\n%d:%d").)
Constraints:
- 0 <= h1, h2 <= 23, 0 <= m1, m2 <= 59
Output
Please output an integer, representing how many minutes Hank can sleep in one day.
(Note: Hank won't wake up naturally; he will only wake up when Noah's alarm goes off.)
Please remember to print "\n" at the end.