1. Two Operations (Programming)
You are given only two operations, ADD_1 and MULTIPLY_2. You start from 0 and using the two operations reach a number N. Find the least number of operations needed to do this.
Input Format:
Given T, T lines follow. Each line contains
N – Number to be formed
Output Format.
Print the minimum number of operations needed in each line corresponding to each test case.
Constraints
T <= 10000 N <= 1016. Sample Input 2 5 3 Sample Output 4 3 Explanation Case1: To reach 5 from 0. We do ADD1 then Multiply2 two times and then add 1 again , total 4 steps Case2: To reach 3 from 0. We can either do Add 1 3 times or Add 1 , multiply 2 and again add 1 2. Rational Sum (Programming) In mathematics, a rational number is any number that can be expressed in the form of a fraction p/q , where p & q are two integers, and the denominator q is not equal to zero. Hence, all integers are rational numbers where denominator, in the most reduced form, is equal to 1. You are given a list of N rational number, {a1/b1, a2/b2, …, aN/bN}. Print the sum ( = a1/b1 + a2/b2 + … + aN/bN = num/den) in the most reduced form.. visit 1point3acres.com for more. Input The first line of input contains an integer, N, the number of rational numbers. N lines follow. ithline contains two space separated integers, ai bi, where aiis the numerator and bi is the denominator for the ith rational number.. Output You have to print two space separated integers, num den, where num and den are numerator and denominator of the sum respectively. Constraints. 1 <= N <= 15 1 <= ai <= 10 1 <= bi <= 10 Notes Make sure the sum displayed as output is in the most reduced form. If sum is an integer, you have to print 1 as denominator.. visit 1point3acres.com for more. Sample Input 4 4 2 2 4 2 4 2 3 Sample Output 11 3 Explanation Sum is 4/2 + 2/4 + 2/4 + 2/3 = (24 + 6 + 6 + 8)/12 = 44/12 = 11/3. So you have to print “11 3″, which is the most reduced form.-google 1point3acres ——————– 有一点比较奇怪的就是，听说Twitter应该是做完笔试再通知phone interview的，但是我笔试都还没做phone interview的邮件就来了_(:з」∠)_ （ps. HackerRank就是好用！） （ps. 发帖的时候选公司那里居然没有Twitter_(:з」∠)_）. from: 1point3acres.com/bbs