Page **1** of **1**

### 10906 - Strange Integration

Posted: **Sun Oct 09, 2005 12:57 pm**

by **DJY**

I think it's an easy recursive problem,

but I have got WA for several times.

Could anyone give me some test data

thx

Posted: **Thu Jan 12, 2006 7:34 pm**

by **Darko**

I can't get this one right either, can someone please check this I/O?

Code: Select all

```
11
2
A = 2 + 3
B = A + A
3
A = 2 + 3
B = A + 4
C = B + 5
6
a = 2 + 3
b = a * 4
c = 2 + 3
d = c * 5
e = b + d
f = e + 6
5
a = 2 + 3
b = a * 4
d = a * 5
e = b + d
f = e + 6
4
a = 3 * 4
b = a + a
c = a * a
d = b + c
4
a = 3 * 4
b = a + a
c = a * a
d = c + b
4
a = 3 + 4
b = a + a
c = a * a
d = c + b
5
a = 3 + 4
b = a + a
c = a * a
d = b + b
e = b * c
4
a = 5 * 6
b = 5 + a
c = 5 + b
d = 5 + c
6
a = 5 * 6
b = 5 + a
c = 5 + b
d = a + 5
e = d * 6
f = c + d
6
a = 5 * 6
b = 5 + a
c = 5 + b
d = a + 5
e = d * 6
f = d + c
```

Code: Select all

```
Expression #1: 2+3+(2+3)
Expression #2: 2+3+4+5
Expression #3: (2+3)*4+(2+3)*5+6
Expression #4: (2+3)*4+(2+3)*5+6
Expression #5: 3*4+3*4+3*4*3*4
Expression #6: 3*4*3*4+3*4+3*4
Expression #7: (3+4)*(3+4)+3+4+(3+4)
Expression #8: (3+4+(3+4))*(3+4)*(3+4)
Expression #9: 5+(5+(5+5*6))
Expression #10: 5+(5+5*6)+(5*6+5)
Expression #11: 5*6+5+(5+(5+5*6))
```

Posted: **Thu Jan 12, 2006 7:57 pm**

by **mf**

My accepted program's output for your input:

Code: Select all

```
Expression #1: 2+3+(2+3)
Expression #2: 2+3+4+5
Expression #3: (2+3)*4+(2+3)*5+6
Expression #4: (2+3)*4+(2+3)*5+6
Expression #5: 3*4+3*4+3*4*(3*4)
Expression #6: 3*4*(3*4)+(3*4+3*4)
Expression #7: (3+4)*(3+4)+(3+4+(3+4))
Expression #8: (3+4+(3+4))*((3+4)*(3+4))
Expression #9: 5+(5+(5+5*6))
Expression #10: 5+(5+5*6)+(5*6+5)
Expression #11: 5*6+5+(5+(5+5*6))
```

Here are some test cases I've made when I were debugging my code:

Code: Select all

```
20
2
A = 2 + 3
B = A + A
3
A = 2 + 3
B = A + 4
C = B + 5
2
a = 2 + 3
b = a * 4
3
c = 3 * 3
b = 2 * c
a = b * b
3
b = 2 * 3
c = 4 * 5
a = b * c
3
c = 1 * 2
b = c * 3
a = b * 4
3
c = 3 * 4
b = 2 * c
a = 1 * b
3
c = 3 * 4
b = c * 2
a = 1 * b
2
c = 1 * 2
b = c + c
2
c = 1 + 2
b = c * c
3
c = 1 * 2
b = c + c
a = c * b
3
c = 1 * 2
b = c + c
a = b * c
3
c = 1 * 2
b = c * c
a = b * c
2
b = 2 * 3
a = 1 + b
2
b = 2 * 3
a = b + 1
2
b = 9999999998 + 9999999997
a = 9999999999 * b
7
d = 1 + 1
e = 2 + 2
f = 3 + 3
g = 4 + 4
b = d + e
c = f + g
a = b + c
7
d = 1 * 1
e = 2 * 2
f = 3 * 3
g = 4 * 4
b = d * e
c = f * g
a = b + c
3
c = 1 + 2
d = 3 * 4
a = c + d
3
c = 1 + 2
d = 3 * 4
a = d + c
```

Output:

Code: Select all

```
Expression #1: 2+3+(2+3)
Expression #2: 2+3+4+5
Expression #3: (2+3)*4
Expression #4: 2*(3*3)*(2*(3*3))
Expression #5: 2*3*(4*5)
Expression #6: 1*2*3*4
Expression #7: 1*(2*(3*4))
Expression #8: 1*(3*4*2)
Expression #9: 1*2+1*2
Expression #10: (1+2)*(1+2)
Expression #11: 1*2*(1*2+1*2)
Expression #12: (1*2+1*2)*(1*2)
Expression #13: 1*2*(1*2)*(1*2)
Expression #14: 1+2*3
Expression #15: 2*3+1
Expression #16: 9999999999*(9999999998+9999999997)
Expression #17: 1+1+(2+2)+(3+3+(4+4))
Expression #18: 1*1*(2*2)+3*3*(4*4)
Expression #19: 1+2+3*4
Expression #20: 3*4+(1+2)
```

Posted: **Thu Jan 12, 2006 8:31 pm**

by **Darko**

Thanks a lot, mf, now it makes sense. It never ocurred to me that the order of evaluation other than the one shown in sample I/O would matter.

Darko