Everyone has silly periods, especially for RenShengGe. It's a sunny day, no one knows what happened to RenShengGe, RenShengGe says that he wants to change all decimal fractions between 0 and 1 to fraction. In addtion, he says decimal fractions are too complicate, and set thatis much more convient than 0.33333... as an example to support his theory.
So, RenShengGe lists a lot of numbers in textbooks and starts his great work. To his dissapoint, he soon realizes that the denominator of the fraction may be very big which kills the simplicity that support of his theory.
But RenShengGe is famous for his persistence, so he decided to sacrifice some accuracy of fractions. Ok, In his new solution, he confines the denominator in [1,1000] and figure out the least absolute different fractions with the decimal fraction under his restriction. If several fractions satifies the restriction, he chooses the smallest one with simplest formation.
The first line contains a number T(no more than 10000) which represents the number of test cases.
And there followed T lines, each line contains a finite decimal fraction x that satisfies.
For each test case, transform x in RenShengGe's rule.
3
0.9999999999999
0.3333333333333
0.2222222222222
1/1
1/3
2/9
You can use double to save x;
#include#include #include #include #include #include