TOHU - Help Tohu
Tohu wants to enter Moscow State University, and he must pass the math exam. He does not know math, and asks you to help him. The problem is to find the sum of the sequence on condition
Input
First line contains single integer T <= 20000 - the number of test cases.
Each of the next T lines contains single integer 1 <= n <= 10^9.
Output
For each n output the value with 11 digits after decimal point.
Example
Input:
2
2
5
Output: 0.70833333333
0.73809523810
hide comments
dashingvimeet:
2015-07-13 16:29:00
By mathematical induction, we found a[sub]1[/sub] and a[sub]2[/sub] as 1 / 6 and 1 / 24 respectively, therefore S[sub]2[/sub] came out to be 0.208333333333. Output shown above is wrong. |
|
[Mayank Pratap]:
2015-07-13 05:33:00
@Dushyant ... Thanks buddy :) |
|
Dushyant Singh:
2015-07-12 18:05:58
@ Mayank - Try VENOM again. Try David and his Obsession it's bit different but mathematical. :-)
|
|
[Mayank Pratap]:
2015-07-12 05:05:36
I enjoyed solving this problem.... Can anyone suggest some more mathematical problems like this ??
|
|
r0bo_dart:
2015-06-18 15:57:04
std::fixed and std::setprecision(k) will be at your disposal :D :P. Then its O(1) if you know the math. |
|
ASHUTOSH DWIVEDI:
2015-05-16 11:21:30
good mathematical problem........ |
|
Mitch Schwartz:
2014-04-09 16:56:42
Images restored. They were originally generated with [math][/math] tags, which are no longer supported on SPOJ. The original LaTeX can be seen by hovering your mouse over the images. |
|
:D:
2012-05-31 10:30:38
Yes, it can be solved in O(1). |
|
:D:
2011-10-06 22:16:27
It's hard (if not impossible) to do without spoiling the problem. Just analyse the given condition and get formula for an or S from it. As you see it's pretty much the same thing. |
Added by: | Efim |
Date: | 2011-06-15 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |