#P7618. [COCI 2011/2012 #2] FUNKCIJA
[COCI 2011/2012 #2] FUNKCIJA
Description
Mirko wrote the following function:
(C++)
int fun() {
int ret = 0;
for (int a = X1; a <= Y1; ++a)
for (int b = X2; b <= Y2; ++b)
...
for (int <N-th> = XN; <N-th> <= YN; ++<N-th>)
ret = (ret + 1) % 1000000007;
return ret;
}
(Pascal)
function fun: longint;
var
ret: longint;
a, b, ... , y, z: longint;
begin
ret := 0;
for a := X1 to Y1 do
for b := X2 to Y2 do
...
for <N-th> := XN to YN do
ret := (ret + 1) mod 1000000007;
fun := ret;
end;
denotes the -th lowercase letter. Each and may represent the variable name of an outer loop, or a positive integer . For example, can be , , or an integer constant. At least one of and is an integer constant.
Compute the return value of this function.
Input Format
The first line contains a positive integer .
The next lines each contain separated by spaces on the -th line. If both and are integer constants, then .
Output Format
Output one integer in a single line, which is the return value of the function.
2
1 2
a 3
5
3
2 3
1 2
1 a
10
3
1 2
a 3
1 b
11
Hint
Constraints
For of the testdata, .
Notes
The score setting of this problem follows the original COCI problem, with a full score of .
Translated from COCI2011-2012 CONTEST #2 T5 FUNKCIJA.
Translated by ChatGPT 5
京公网安备 11011102002149号