You are given two integers A and B. A represents a coordinate on the x-axis(0,A) and B represents a coordinate on the y-axis (B,0).
These are two coordinates points of a rihjt angled trisngle, the third point being the origin(0,0). You will be given N such triangles in the input. Find out and print the length of the hypotenuse of all the triangles.
Note:
Input Format:
The input consist is given in the following format:
The input will be read from the STDIN by the candidate.
Output Format:
The output consists of N lines:
The output will be matched to the candidate's output printed on the STDOUT.
Constraints:
Example
Input:
2
20 21
8 15
Output:
29
17
Explanation:
The test case contains two triangles:
First triangle:
The hypotenuse = root (20^2+21^2) = 29
Second triangle:
The hypotenuse = root (8^2+15^2) = 17
Reverse the bits of an 32 bit unsigned integer A.
Problem Constraints 0 <= A <= 232
Input Format First and only argument of input contains an integer A.
Output Format Return a single unsigned integer denoting the decimal value of reversed bits.
Example 1
Input:
0
Output:
0
Explanation 1:
00000000000000000000000000000000
00000000000000000000000000000000
Example 2
Input:
3
Output:
3221225472
Explanation:
00000000000000000000000000000011
11000000000000000000000000000000
You are given four integers a, b, c, and d. Find the sum of negative numbers out of these four numbers and print the same.
The input consists offi single line:
The line contains four integers a, b, c, and d.
The input will be read from the STDIN by the candidate
Print the sum of negative numbers out of these four numbers.
The output will be matched to the candidate's output printed on the STDOUT
-103 ≤ a ≤ 103.
-103≤ b. ≤ 103
-103≤ c. ≤ 103
-103≤ d. ≤ 103
Question 1
Overview
Solution
hypot(adjacent,opposite)
but for those who code in java or c++ can easily compute the length by hypotenuse= Math.sqrt((adjacent*adjacent)+(opposite*opposite))
.Question 2
Overview
Solution
Now you need to left shift N_reverse 5 more times and you get the exact reverse that is 01100000.
`
while (num) {
reverse_num <<= 1;
reverse_num |= num & 1;
num >>= 1;
count--;
}`
time complexity :(logN)
Question 3
Overview
Solution