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.
Input
The first line of the input contains number t – the number of tests. Then t test descriptions follow. Each test consists of the single integer n.
Constraints
1 <= t <= 10000
1 <= n <= 106
Output
For each test print the needed ratio with six digits in the fractional part.
Example
Input: 2 1 2 Output: 1.000000 1.200000
hide comments
smso:
2019-09-04 09:20:23
I used double, no need for BigInt Last edit: 2019-10-20 18:45:35 |
|
farhad chowdhury:
2016-04-28 10:28:07
do i require bignum or there is a technique for finding ratio
|
|
kamran siddique:
2015-04-17 12:25:51
Or any thing else there are lot of possiblities Last edit: 2015-04-17 12:26:40 |
|
Ankit Jhawar:
2013-05-27 14:15:28
What is the answer for n=1000000? |
|
Andy:
2012-04-24 15:57:38
:) Last edit: 2012-04-30 17:02:09 |
|
YYOrz:
2011-08-15 12:46:23
It will cause accuracy problems with double?
|
|
alone:
2010-02-09 18:59:09
@above
|
|
Jorge Luis Roque Alvarez:
2009-12-21 20:35:09
for n=2
|
|
যোবায়ের:
2009-11-05 11:44:31
@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 :
2009-11-05 11:19:48
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 |
Added by: | Spooky |
Date: | 2009-11-03 |
Time limit: | 0.800s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 NODEJS OBJC PERL6 SQLITE VB.NET |
Resource: | Advancement Autumn 2009, http://sevolymp.uuuq.com/, author: Alexey Shchepin |