MONONUM - Monotonous numbers
Some integers possess interesting quality: each of their digits is not greater than the digit to the right. Let us define such integers as increasing integers. And let's call integers for which each digit is not lesser than the digit to the right decreasing integers. For example 24558 is increasing, 888410 is decreasing and 5 - is both increasing and decreasing. Given n calculate the ratio of the decreasing n-digit integers to the increasing n-digit integers. We consider only positive integers. Leading zeros are not allowed.
The first line of the input contains number t – the amount of tests. Then t test descriptions follow. Each test consists of the single integer n
1 <= t <= 10000
1 <= n <= 106
For each test print the needed ratio with six digits in the fractional part.
Input: 2 1 2 Output: 1.000000 1.200000
do i require bignum or there is a technique for finding ratio
Or any thing else there are lot of possiblitiesLast edit: 2015-04-17 12:26:40
What is the answer for n=1000000?
:)Last edit: 2012-04-30 17:02:09
It will cause accuracy problems with double?
Jorge Luis Roque Alvarez:
@krishna, read again, the input is not the number, it is the number of digits you need to consider...[edit: Sorry for my mistake, George is right, I forgot to count the equal ones]Last edit: 2009-11-06 18:02:23
krishna kant :
How output can be 1.2 for 2 as a input, it should be 1.0. As 2 is increasing ang decreasing both.Last edit: 2009-11-05 11:21:51