1 条题解
-
0
Pascal :
var a:array[1..150]of longint; v:array[1..10,1..10]of boolean; c,d:array[1..150]of boolean; b:array[1..11]of longint; i,j,k,l,m,n,num,p,q,sum,an:longint; found:boolean; begin read(n); m:=n*(n-1)div 2; for i:=1 to m do read(a[i]); fillchar(v,sizeof(v),true); fillchar(c,sizeof(c),true); for i:=1 to m-1 do for j:=i+1 to m do begin if a[i]>a[j] then begin k:=a[i]; a[i]:=a[j]; a[j]:=k; end; end; if a[1] mod 2 =0 then an:=a[1] div 2-1 else an:=a[1] div 2; for i:=0 to an do begin fillchar(c,sizeof(c),true); fillchar(v,sizeof(v),true); num:=1; b[1]:=i; sum:=0; repeat for j:=1 to m do if c[j]<>false then break; c[j]:=false; inc(num); b[num]:=a[j]-b[1]; l:=num*(num-1)div 2; for k:=1 to m do begin for p:=1 to num-1 do for q:=p+1 to num do begin if (a[k]=b[p]+b[q])and (v[p,q]<>false) then begin v[p,q]:=false; v[q,p]:=false; c[k]:=false; inc(sum); end; end; end; if sum<>l then begin found:=false; end else found:=true; until (num=n)or (found=false); if (found=false)and (i=an) then begin writeln('Impossible'); halt; end; if found=false then continue; if num=n then begin for k:=1 to num-1 do write(b[k],' '); writeln(b[k+1]); halt; end; end; end.
- 1
信息
- ID
- 3380
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者