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.

Constraints :

t <= 1000000

0 <= n <= 1000000

Sample Input 1:

3

1

2

3

Sample Output 1:

0.333333 4.000000

Sample Input 2 :

2

5

6

Sample Output 2 :

0.000000 3.500000

Explanation :

Case 2 : 5 -> 3,5,6 and 6-> 5,6,9 are the required numbers.


hide comments
pandey101299: 2019-07-22 06:50:16

question statement should be clear

ragwave: 2016-05-27 11:21:18

Last edit: 2016-05-27 12:53:16
ragwave: 2016-05-27 11:12:14

what do u mean by " mean" of stardom of salman over srk.....Care to explain!!

Last edit: 2016-05-27 11:12:52
Raj Kumar: 2015-01-09 13:46:07

Is there any specific format for printing the output?

shiv prasad chabarval: 2014-09-25 15:54:44

@pranjuldb my code got AC on hackerrank is giving TLE here. why??
pranjuldb : due to strict time-limit. try to optimize :)

Last edit: 2014-10-01 09:19:02
Siya: 2014-09-25 01:55:52

After so many TLE finally AC :) :)

Last edit: 2014-09-25 03:51:24
pranjuldb: 2014-09-09 14:55:46

@LeppyR64 Read the problem statement again. You are not doing it in a right way.

LeppyR64: 2014-09-09 14:42:26

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

pranjuldb: 2014-09-09 14:09:51

@Jacob and @humble_coder problem statement is now clear.

Jacob Plachta: 2014-09-09 14:08:28

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.


Added by:pranjuldb
Date:2014-09-08
Time limit:0.899s
Source limit:50000B
Memory limit:1536MB
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