KHANS - Alia and 3 Khans
3 KHANS of Bollywood are planning to work together in a film called "Three_Khans". Aamir (being perfect :P) wants the Alia to be a main lead. But Alia (being very famous :P) is confused that whether to work in a film or not. So they all have decided to play a game called "Filmy_Sequence".
According to this game, Aamir will give any number to Alia to play with it. Alia has to find two other numbers using it. That two numbers represent Stardom of Salman and Srk. These two numbers shoud be found in such a way so that both numbers will have same number of set ('1') bits in their binary representation as Aamir's number contains. One thing is also need to be checked that Salman's number should be just next greater number to Aamir's number and Srk's number should be just next smaller number to Aamir's number (i.e in a order of their Stardom :P). They all have decided that if this "Filmy_Sequence" forms a G.P (Geometric Progression) then Alia has to be in the favour of movie else not. Alia needs your help to find the probabilty that she will work in a film and she also wants to find the mean of the Stardum of Salman over Srk.
Note : All the three numbers should be positive and in a range upto 32 bits, and if not possible assume -1. (i.e if particular number is not possible with respect to Aamir's number, assume it as -1)
Input Format :
first line will have a number of numbers that Aamir will give (t) next t lines will have Aamir's number (n)
Output Format :
print the asked probability and mean. Any results within 10^-6 absolute error will be accepted.
t <= 1000000
0 <= n <= 1000000
Sample Input 1:
Sample Output 1:
Sample Input 2 :
Sample Output 2 :
Case 2 : 5 -> 3,5,6 and 6-> 5,6,9 are the required numbers.
question statement should be clear
Last edit: 2016-05-27 12:53:16
what do u mean by " mean" of stardom of salman over srk.....Care to explain!!Last edit: 2016-05-27 11:12:52
Is there any specific format for printing the output?
shiv prasad chabarval:
@pranjuldb my code got AC on hackerrank is giving TLE here. why??
After so many TLE finally AC :) :)Last edit: 2014-09-25 03:51:24
@LeppyR64 Read the problem statement again. You are not doing it in a right way.
I don't understand how the 3.5 is calculated for the mean in test case #2. Salman/Srk for 5 is 2.0 (6/3) Salman/Srk for 6 is 1.8 (9/5). (2.0 + 1.8)/2.0 = 1.9
@Jacob and @humble_coder problem statement is now clear.
A necessary clarification is that Salman and Srk's numbers should each be changed to -1 if they don't satisfy the given conditions, but Aamir's number should never be changed.
|Cluster:||Cube (Intel G860)|
|Languages:||All except: ASM32 ASM64 GAWK BASH CLPS CLOJURE D ERL FORTRAN GO ICON ICK LUA NEM NICE NODEJS OCAML PAS-GPC PAS-FPC PIKE RUBY SCALA SCM qobi SCM guile SED ST TCL WHITESPACE|
|Resource:||Own problem from Codehurdle|