logo AlgoBeat OnlineJudge
登录 注册

#206182. [NWRRC 2017] Fygon 2.0

内存限制:512 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

The new version of beloved programming language Fygon has been released! The brand new Fygon . still has only two statements. The first statement is lag. It substitutes almost any other statement. Second statement is a for loop:

for <variable> in range(<from>, <to>):
    <body>

The for loop makes iterate from to , both inclusive.

If is greater than , is not executed at all.

is a lowercase letter from a to , except for , which is a variable that is defined prior to the given code snippet.

and can be equal to any variable defined in outer loop. In addition to that, can be and can be .

The of the loop is indented by four spaces and contains at least one statement.

If you are familiar with Fygon . , you can notice that, in the spirit of the best programming practices, Fygon . is not backwards compatible, since the range function now requires two parameters.

The performance of the new version is significantly improved, so you can write more nested for loops. That is why we are no longer interested in the exact number of operations, but in the asymptotic complexity of the program instead. For simplicity, all for loops are nested in a single chain and there is exactly one lag statement that is inside all for loops. All loop variables are different and are not equal to .

Let's define as the number of lag operations exectuted by a given Fygon program as the function of . For non-negative integer and positive rational number we say that is the asymptotic complexity of the program if

Given a Fygon . program, find its asymptotic complexity.

输入格式

The first line of the input contains single integer -- the number of lines in Fygon . program. Next lines contain the program itself. The program has at least and at most for statements. Each for statement contains either single nested for statement or lag statement.

输出格式

Output numbers and . should be output in the form of irreducible fraction , where and are coprime.

样例

样例输入 1

4
for i in range(1, n):
    for j in range(1, i):
        for k in range(j, n):
            lag

样例输出 1

3 1/3

数据范围与提示

Time limit: 3 s, Memory limit: 512 MB.