#include <iostream>
#include <sstream>
#include <utility>
#include <string>
#include <cmath>
#include <limits>

typedef std::pair<int, int> Fraction;

int gcd(int a, int b) {
    int c;
    while (a != 0) {
        c = a;
        a = b % a;
        b = c;
    }
    return b;
}

int wholeDigits(double x) {
	if (x < 1)
		return 0;
    return (int)log10(x) + 1;
}

Fraction decToFrac(double x) {
    bool isNegative = x < 0.0;
    x = std::abs(x);
    
    if (x > std::numeric_limits<int>::max())
        return std::make_pair(isNegative ? -1 : 1, 0);
    
    std::ostringstream os;
    os.precision(9 - wholeDigits(x)); // int na wiecej nie pozwala
    os << std::fixed << x;
    std::string numStr = os.str();
    int pointPos = numStr.find_last_of('.');
    numStr.erase(pointPos, 1);
    int fracDigits = numStr.size() - pointPos;
    
    int numerator;
    std::istringstream is(numStr);
    is >> numerator;
    
    int denominator = 1;
    while (fracDigits--)
        denominator *= 10;
    
    int d = gcd(numerator, denominator);
    numerator /= d;
    denominator /= d;
    
    if (isNegative)
        numerator = -numerator;
    
    return std::make_pair(numerator, denominator);
}

std::string print(Fraction f) {
    std::ostringstream os;
    os << f.first << " / " << f.second;
    return os.str();
}

int main() {
    std::cout 
        << print(decToFrac(1)) << std::endl
        << print(decToFrac(100.1)) << std::endl
        << print(decToFrac(0.001)) << std::endl
        << print(decToFrac(123.456)) << std::endl
        << print(decToFrac(-654.321)) << std::endl
        << print(decToFrac(1e-15)) << std::endl
        << print(decToFrac(1e15)) << std::endl;
}
