program r1(input,output);
uses crt;
var x,a,b,c,d,k,l,i,z:longint;
        p:string;
        q,vih:char;
        fa,fb,fc,fd:boolean;
{---------------------------------------------------------------------------}
procedure inprov(var x:longint; var f:boolean);
var z:integer;
        p:string;
        q:char;
        j:boolean;
begin
x:=0;
j:=true;
read (q);
if q='-' then
begin
j:=false;
read (q)
end;
while (q<>' ') do
        begin
        if (ord(q)<48) or (ord(q)>57) then
                begin
                f:=false;
                break
                end;
        x:=10 * x+ ord(q) - 48;
        read (q)
        end;
if not j then x:=-x;
end;
{---------------------------------------------------------------------------}
begin clrscr;
repeat
readln;
fa:=true;
fb:=true;
fc:=true;
fd:=true;
writeln ('Input koefficienti');
writeln ('Koefficienti vvodatsa cherez probel i ih vsego 4');
writeln ('posle 4-ogo koefficienta probel obazatelen!');
writeln ('vse cho vvedeno posle 4-ogo probela ne rassmatrivaetsa');
writeln;
inprov (a,fa);
if a=0 then
        begin
        fa:=false;
        writeln ('it is not cubic equation');
        end;
inprov (b,fb);
inprov (c,fc);
inprov (d,fd);
writeln;
writeln ('Inputing is finished');
if fa and fb and fc and fd then begin
        readln;
        k:=0;
        i:=1;
        if abs(d)<=abs(a) then
        begin
        if d=0 then
                begin
                if c=0 then
                if b=0 then writeln ('Integer solution is 0')
                else
                        begin
                        if b mod a = 0 then
                                begin
                                k:= b div a;
                                writeln ('Integer solution(-s):');
                                writeln ('1-st Integer solution is 0');
                                writeln ('2-st Integer solution is ',-k)
                                end
                        else writeln ('Integer solution is 0')
                        end
                else
                begin
                for i:=1 to abs(c) do
                if (abs(c) mod i)=0 then
                        begin
                        if (a*sqr(i)+b*i+c)=0 then
                                begin
                                k:=k+1;
                                        case k of
                                                1:begin
                                                writeln ('Integer solution(-s):');
                                                writeln (' ',k,'-st = ',i)
                                                end;
                                                2:  writeln (' ',k,'-nd = ',i)
                                                end
                                end;
                        if (-a*sqr(i)+b*i-c)=0 then
                                begin
                                k:=k+1;
                                        case k of
                                                1:begin
                                                writeln ('Integer solution(-s):');
                                                writeln (' ',k,'-st = ',-i)
                                                end;
                                                2: writeln (' ',k,'-nd = ',-i)
                                        end;
                                end;
                        writeln (' ','last = 0');
                        K:=1
                        end
                end
        end
        else
        begin
        for i:=1 to abs(d) do
                if (abs(d) mod i)=0 then
                        begin
                        if (a*i*sqr(i)+b*sqr(i)+c*i+d)=0 then
                                begin
                                k:=k+1;
                                        case k of
                                                1:begin
                                                writeln ('Integer solution(-s):');
                                                writeln (' ',k,'-st = ',i)
                                                end;
                                                2:  writeln (' ',k,'-nd = ',i);
                                                3:  writeln (' ',k,'-rd = ',i);
                                                end
                                        end;
                        if (-a*i*sqr(i)+b*sqr(i)-c*i+d)=0 then
                                begin
                                k:=k+1;
                                        case k of
                                                1:begin
                                                writeln ('Integer solution(-s):');
                                                writeln (' ',k,'-st = ',-i)
                                                end;
                                        2:  writeln (' ',k,'-nd = ',-i);
                                        3:  writeln (' ',k,'-rd = ',-i);
                                        end
                                end
                        end
                else writeln ('No Integer solutions')
                end
        end;
        if k=0 then writeln('No integer solutions');
        writeln;
        writeln ('Outputing is finished')
END
else
        begin
        writeln ('This input is incorrect');
        writeln ('YOU ARE STUPID!!!');
        writeln
        END;
readln;
writeln ('Do you want to continue computings? ');
writeln ('0-no, others-yes');
readln (vih);
until vih='0';
writeln ('thank you for using my programm!');
readln
end.





