Pagini recente » Cod sursa (job #2744917) | Cod sursa (job #1277696) | Cod sursa (job #726708) | Cod sursa (job #713803) | Cod sursa (job #82814)
Cod sursa(job #82814)
var f1,f2:text;
a:array[1..50000] of longint;
c:array[1..50000] of char;
i,n,x:longint;
s,sg:int64;
begin
randomize;
assign(f1,'semne.in');
reset(f1);
assign(f2,'semne.out');
rewrite(f2);
read(f1,n,s);
for i:=1 to n do
read(f1,a[i]);
while sg<>s do
begin
sg:=0;
for i:=1 to n do
begin
x:=random(2);
if x=0 then
begin
c[i]:='+';
sg:=sg+a[i];
end
else
begin
c[i]:='-';
sg:=sg-a[i];
end;
end;
end;
for i:=1 to n do write(f2,c[i]);
close(f1);
close(f2);
end.