<p>Given two strings <code>s</code> and <code>t</code>, each of which represents a non-negative rational number, return <code>true</code> if and only if they represent the same number. The strings may use parentheses to denote the repeating part of the rational number.</p>

<p>A <strong>rational number</strong> can be represented using up to three parts: <code>&lt;IntegerPart&gt;</code>, <code>&lt;NonRepeatingPart&gt;</code>, and a <code>&lt;RepeatingPart&gt;</code>. The number will be represented in one of the following three ways:</p>

<ul>
	<li><code>&lt;IntegerPart&gt;</code>

	<ul>
		<li>For example, <code>12</code>, <code>0</code>, and <code>123</code>.</li>
	</ul>
	</li>
	<li><code>&lt;IntegerPart&gt;<strong>&lt;.&gt;</strong>&lt;NonRepeatingPart&gt;</code>
	<ul>
		<li>For example, <code>0.5</code>, <code>1.</code>, <code>2.12</code>, and <code>123.0001</code>.</li>
	</ul>
	</li>
	<li><code>&lt;IntegerPart&gt;<strong>&lt;.&gt;</strong>&lt;NonRepeatingPart&gt;<strong>&lt;(&gt;</strong>&lt;RepeatingPart&gt;<strong>&lt;)&gt;</strong></code>
	<ul>
		<li>For example, <code>0.1(6)</code>, <code>1.(9)</code>, <code>123.00(1212)</code>.</li>
	</ul>
	</li>
</ul>

<p>The repeating portion of a decimal expansion is conventionally denoted within a pair of round brackets. For example:</p>

<ul>
	<li><code>1/6 = 0.16666666... = 0.1(6) = 0.1666(6) = 0.166(66)</code>.</li>
</ul>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;0.(52)&quot;, t = &quot;0.5(25)&quot;
<strong>Output:</strong> true
<strong>Explanation:</strong> Because &quot;0.(52)&quot; represents 0.52525252..., and &quot;0.5(25)&quot; represents 0.52525252525..... , the strings represent the same number.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;0.1666(6)&quot;, t = &quot;0.166(66)&quot;
<strong>Output:</strong> true
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;0.9(9)&quot;, t = &quot;1.&quot;
<strong>Output:</strong> true
<strong>Explanation:</strong> &quot;0.9(9)&quot; represents 0.999999999... repeated forever, which equals 1.  [<a href="https://en.wikipedia.org/wiki/0.999..." target="_blank">See this link for an explanation.</a>]
&quot;1.&quot; represents the number 1, which is formed correctly: (IntegerPart) = &quot;1&quot; and (NonRepeatingPart) = &quot;&quot;.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li>Each part consists only of digits.</li>
	<li>The <code>&lt;IntegerPart&gt;</code> does not have leading zeros (except for the zero itself).</li>
	<li><code>1 &lt;= &lt;IntegerPart&gt;.length &lt;= 4</code></li>
	<li><code>0 &lt;= &lt;NonRepeatingPart&gt;.length &lt;= 4</code></li>
	<li><code>1 &lt;= &lt;RepeatingPart&gt;.length &lt;= 4</code></li>
</ul>

class Solution {
public:

    bool isRationalEqual(string s, string t) {

        int ind1 = 0, ind2 = 0, i3 = 0;
        int n = s.size(), m = t.size();

        while(s[ind1] != '(' && ind1 < n){
            ind1++;
        }
        while(t[ind2] != '(' && ind2 < m){
            ind2++;
        }
        string rep1 = "", rep2 = "";
        int i1 = ind1 + 1, i2 = ind2 + 1;
        while(s[i1] != ')' && i1 < n) {
            rep1 += s[i1];
            i1++;
        }
        while(t[i2] != ')' && i2 < m) {
            rep2 += t[i2];
            i2++;
        }
        bool dot1 = false, dot2 = false;
        for(int i = 0; i < n; i++) if(s[i] == '.') dot1 = true;
        for(int i = 0; i < m; i++) if(t[i] == '.') dot2 = true;
        
        cout << rep1 << " " << rep2 << endl;

        string a1 = s.substr(0,ind1), a2 = t.substr(0,ind2);
        if(!dot1) a1 += '.';
        if(!dot2) a2 += '.';
        if(rep1 == "")rep1 = '0';
        if(rep2 == "")rep2 = '0';

        while(a1.size() <= 50) {
            cout << a1 << endl;
            a1 += rep1;
        }
        while(a2.size() <= 50) a2 += rep2;

        cout << a1 << " " << a2 << endl;

        int k = min(a1.size(), a2.size());

        return stod(a1.substr(0,k)) == stod(a2.substr(0,k));

        
    }
};
7700