Submit | All submissions | Best solutions | Back to list |
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. Those two numbers represent Stardom of Salman and Srk. These two numbers should 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 probability that she will work in a film and she also wants to find the mean of the Stardom of Salman over Srk.
Note: All the three numbers should be positive and in a range up to 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
The first line will have a number of numbers that Aamir will give (t) next t lines will have Aamir's number (n).
Output
Print the asked probability and mean. Any results within 10-6 absolute error will be accepted.
Constraints
t ≤ 1000000
0 ≤ n ≤ 1000000
Example
Input 1: 3 1 2 3 Output 1: 0.333333 4.000000
Input 2: 2 5 6 Output 2: 0.000000 3.500000
Explanation
Case 2 : 5 → 3, 5, 6 and 6 → 5, 6, 9 are the required numbers.
Added by: | pranjuldb |
Date: | 2014-09-08 |
Time limit: | 1s |
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 guile SCM qobi SED ST TCL WHITESPACE |
Resource: | Own problem from Codehurdle |
hide comments
|
|||||
2019-07-22 06:50:16
question statement should be clear |
|||||
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 |
|||||
2015-01-09 13:46:07 Raj Kumar
Is there any specific format for printing the output? |
|||||
2014-09-25 15:54:44 shiv prasad chabarval
@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 |
|||||
2014-09-25 01:55:52 Siya
After so many TLE finally AC :) :) Last edit: 2014-09-25 03:51:24 |
|||||
2014-09-09 14:55:46 pranjuldb
@LeppyR64 Read the problem statement again. You are not doing it in a right way. |
|||||
2014-09-09 14:42:26 LeppyR64
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 |
|||||
2014-09-09 14:09:51 pranjuldb
@Jacob and @humble_coder problem statement is now clear. |
|||||
2014-09-09 14:08:28 Jacob Plachta
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. |
|||||
2014-09-09 14:02:19 humble_coder
problem statement should be made more clear.. |