Cod sursa(job #111062)
Utilizator | Data | 28 noiembrie 2007 16:14:51 | |
---|---|---|---|
Problema | Ecuatie | Scor | 0 |
Compilator | fpc | Status | done |
Runda | Arhiva de probleme | Marime | 3.06 kb |
var f,g:text;
k,a,b,c,d,n,p1,p2,q1,q2:integer;
begin
assign(f,'ecuatie.in');reset(f);
assign(g,'ecuatie.out');rewrite(g);
read(f,a,b,c,n);
for p1:=-c to c do
if k<n then
for p2:=-c to c do
if k<n then
if p1*p2=a then
for q1:=-c to c do
if k<n then
for q2:=-c to c do
if k<n then
if (p1*q2+p2*q1=b) and (q1*q2=c) then
begin
inc(k);
if k=n then
begin
a:=p1;
b:=p2;
c:=q1;
d:=q2;
end;
end;
p1:=a;
p2:=b;
q1:=c;
q2:=d;
if p1=1 then
if p2=1 then
if q1<0 then
if q2<0 then
writeln(g,'(x',q1,')(x',q2,')')
else
writeln(g,'(x',q1,')(x+',q2,')')
else
if q2<0 then
writeln(g,'(x+',q1,')(x',q2,')')
else
writeln(g,'(x+',q1,')(x+',q2,')')
else
if q1<0 then
if q2<0 then
writeln(g,'(x',q1,')(',p2,'x',q2,')')
else
writeln(g,'(x',q1,')(',p2,'x+',q2,')')
else
if q2<0 then
writeln(g,'(x+',q1,')(',p2,'x',q2,')')
else
writeln(g,'(x+',q1,')(',p2,'x+',q2,')')
else
if p2=1 then
if q1<0 then
if q2<0 then
writeln(g,'(',p1,'x',q1,')(x',q2,')')
else
writeln(g,'(',p1,'x',q1,')(x+',q2,')')
else
if q2<0 then
writeln(g,'(',p1,'x+',q1,')(x',q2,')')
else
writeln(g,'(',p1,'x+',q1,')(x+',q2,')')
else
if q1<0 then
if q2<0 then
writeln(g,'(',p1,'x',q1,')(',p2,'x',q2,')')
else
writeln(g,'(',p1,'x',q1,')(',p2,'x+',q2,')')
else
if q2<0 then
writeln(g,'(',p1,'x+',q1,')(',p2,'x',q2,')')
else
writeln(g,'(',p1,'x+',q1,')(',p2,'x+',q2,')');
close(f);
close(g);
end.