1200 - A DP Problem


Difficulty : easy

Solution Description :

String processing problem

Do this what is say in question description.

Find the total co-efficient of x.
Example: 2x+10-x=20-x => 2x-x+x=20-10 => 2x = 10 (Here total co-efficient of x is 2)

1. If the total co-efficient of x is not zero then print (total sum of constant)/(total co-efficient of x)
For 2x+10-x=20-x ans = 10/2 = 5.
Read this line carefully "the floor of s, i.e., the largest integer number less than or equal to s"
Example: 2x=5  => x = 5/2 = 2.5 Floor of 2.5 is 2. So, ans is 2.
         2x=-5 => x =-5/2 =-2.5 Floor of -2.5 is -3. So, ans is -3.

2. If the total co-efficient of x is zero then ans must be IMPOSSIBLE or IDENTITY
Example: 2x+10-x=20+x => 2x-x-x=20-10 => 0x = 10 (Here total co-efficient of x is zero)
If sum of integer value is zero then print "IDENTITY"
Otherwise print "IMPOSSIBLE"
Example: 2x+10-5-x=5+x => 2x-x-x=5-10+5 => 0x=0 print "IDENTITY"
         2x+10=20+2x => 2x-2x=20-10 => 0x=10 print "IMPOSSIBLE"