## 10906 - Strange Integration

Moderator: Board moderators

DJY
New poster
Posts: 5
Joined: Sun Oct 12, 2003 9:24 am

### 10906 - Strange Integration

I think it's an easy recursive problem,
but I have got WA for several times.

Could anyone give me some test data
thx

Darko
Guru
Posts: 580
Joined: Fri Nov 11, 2005 9:34 am
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))
``````

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:
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)
``````

Darko
Guru
Posts: 580
Joined: Fri Nov 11, 2005 9:34 am