# Poj Solution 2295

```http://poj.org/problem?id=2295

//* @author popop0p0popo
import java.util.*;
import java.io.*;

public class Main{
public static void main(String[] args) throws Exception{
String f;
String[] t;
double a1,a2,b1,b2;
for (int i=0;i< n ;i++ ){
a1=0;
a2=0;
b1=0;
b2=0;
t=f.split("=");
String e="";
char oper='+';
for (int j=0;j< t.length() ;j++ ){
if (t.charAt(j)=='-'||t.charAt(j)=='+'){
if (e.charAt(e.length()-1)=='x'){
if (e.equals("x")){
e="1x";
}
a1=a1+Double.parseDouble(oper+e.substring(0,e.length()-1));
}
else{
b1=b1+Double.parseDouble(oper+e);
}
oper=t.charAt(j);
e="";
}
else{
if (t.charAt(j)!=' '){
e=e+t.charAt(j);
}
}
}
if (!e.equals("")){
if (e.charAt(e.length()-1)=='x'){
if (e.equals("x")){
e="1x";
}
a1=a1+Double.parseDouble(oper+e.substring(0,e.length()-1));
}
else{
b1=b1+Double.parseDouble(oper+e);
}
}
e="";
oper='+';
for (int j=0;j< t.length() ;j++ ){
if (t.charAt(j)=='-'||t.charAt(j)=='+'){
if (e.charAt(e.length()-1)=='x'){
if (e.equals("x")){
e="1x";
}
a2=a2+Double.parseDouble(oper+e.substring(0,e.length()-1));
}
else{
b2=b2+Double.parseDouble(oper+e);
}
e="";
oper=t.charAt(j);
}
else{
if (t.charAt(j)!=' '){
e=e+t.charAt(j);
}
}
}
if (!e.equals("")){
if (e.charAt(e.length()-1)=='x'){
if (e.equals("x")){
e="1x";
}
a2=a2+Double.parseDouble(oper+e.substring(0,e.length()-1));
}
else{
b2=b2+Double.parseDouble(oper+e);
}
}
if (a1==a2){
if (b1==b2){
System.out.println("IDENTITY");
}
else{
System.out.println("IMPOSSIBLE");
}
}
else{
System.out.println((int)Math.floor((b2-b1)/(a1-a2)));
}
}
}
}

```
This entry was posted in poj. Bookmark the permalink.