## 1. Abridged Problem Statement

Given two positive integers x (numerator) and y (denominator), consider the decimal expansion of x/y. Determine:
- the number of digits after the decimal point before the repeating cycle begins (the non-recurring part length), and
- the length of the repeating cycle.

If the decimal terminates, the repeating cycle length is 0.

---

## 2. Detailed Editorial

### Observation

When you perform long division of x by y in base 10, you generate a sequence of remainders r_0, r_1, r_2, ... where r_0 = x mod y and r_{k+1} = (r_k * 10) mod y.
- If at some step r_k = 0, the division terminates (finite decimal).
- Otherwise, since there are only y possible nonzero remainders, eventually a remainder must repeat. The first time you see a previously seen remainder, you have detected the start of a cycle.

### Definitions

- Let visited[r] = the step index at which remainder r first appeared (0-based for the first digit after the decimal).
- Suppose at step k we get remainder r that was first seen at step j = visited[r].
  - The non-recurring length = j.
  - The cycle length = k - j.
- If we see remainder 0 at step k (and never saw 0 before), then the decimal terminates after k digits and cycle length = 0.

### Algorithm

1. Compute the initial remainder rem = x mod y.
2. Initialize a vector `visited` of size y, filled with -1.
3. Set digits = 0.
4. While rem != 0 and visited[rem] == -1:
   - visited[rem] = digits
   - rem = (rem * 10) mod y
   - digits++
5. If rem == 0, the decimal terminates:
   - non_recurring = digits, cycle_length = 0
6. Else rem repeated:
   - cycle_length = digits - visited[rem]
   - non_recurring = digits - cycle_length
7. Print non_recurring and cycle_length.

### Complexity

Each iteration either stops (rem = 0) or marks a new remainder. There are at most y iterations, so O(y) time and O(y) memory. With y <= 10^6, this is efficient.

---

## 3. C++ Solution

```cpp
#include <bits/stdc++.h>

using namespace std;

template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& x) {
    return out << x.first << ' ' << x.second;
}

template<typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& x) {
    return in >> x.first >> x.second;
}

template<typename T>
istream& operator>>(istream& in, vector<T>& a) {
    for(auto& x: a) {
        in >> x;
    }
    return in;
};

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
    for(auto x: a) {
        out << x << ' ';
    }
    return out;
};

int64_t x, y;

void read() {
    cin >> x >> y;
}

void solve() {
    // Simulate long division of x by y digit by digit. The state at each step
    // is the current remainder; the next remainder is (rem * 10) % y. A finite
    // expansion is reached when the remainder hits 0; a recurring part begins
    // when a remainder repeats.
    //
    // visited[rem] stores the digit index at which remainder rem was first
    // seen. When rem == 0 we stop with no recurring part (length 0). When a
    // remainder repeats, the cycle length is the difference between the current
    // digit index and the index where that remainder first appeared, and the
    // non-recurring prefix length is digits - cycle_length.

    vector<int64_t> visited(y, -1);
    int64_t rem = x % y;
    int64_t digits = 0;
    while(rem != 0 && visited[rem] == -1) {
        visited[rem] = digits;
        rem = (rem * 10) % y;
        digits++;
    }

    int64_t non_recurring, cycle_length;
    if(rem == 0) {
        non_recurring = digits;
        cycle_length = 0;
    } else {
        cycle_length = digits - visited[rem];
        non_recurring = digits - cycle_length;
    }

    cout << non_recurring << ' ' << cycle_length << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    // cin >> T;
    for(int test = 1; test <= T; test++) {
        read();
        // cout << "Case #" << test << ": ";
        solve();
    }

    return 0;
}
```

---

## 4. Python Solution

```python
def find_decimal_info(x, y):
    # visited[r] = index of digit when remainder r first appeared (-1 if unseen)
    visited = [-1] * y

    # initial remainder after integer part
    rem = x % y
    step = 0  # number of digits generated so far

    # long division simulation
    while rem != 0 and visited[rem] == -1:
        visited[rem] = step
        rem = (rem * 10) % y
        step += 1

    # if remainder became zero, decimal terminates
    if rem == 0:
        return step, 0  # non-recurring = step, cycle length = 0

    # found a cycle: starts at visited[rem], length = current step - start
    start = visited[rem]
    cycle_len = step - start
    return start, cycle_len

def main():
    x, y = map(int, input().split())
    non_rec, cycle = find_decimal_info(x, y)
    print(non_rec, cycle)

if __name__ == "__main__":
    main()
```

---

## 5. Compressed Editorial

Track remainders during long division of x by y. Record the first occurrence index of each remainder in an array. Upon seeing remainder 0, decimal terminates; non-recurring = number of digits produced, cycle = 0. Upon seeing a repeated remainder r, cycle_length = digits - visited[r] and non-recurring = digits - cycle_length. Time and memory O(y).
