На форумі обговорюються лише питання, пов'язані з олімпіадою
Ви не зайшли.

Олимпиада окончена... Можно ли начать обговаивать идеи решений и публиковать алгоритмы на данном форуме?
Поза форумом

після 24.00 ти можеш робити все що хочеш:-)))
Поза форумом
Ну что, делимся решениями? Думаю, обговаривать ИДЕИ смысла нет - слишком простые.
Поза форумом

угу, давайте...
Поза форумом

program SuperNet;
var R, N, L, I, Res : longint;
begin
                   read(R,N);
                   Res := 0;
                  if N > R then
                   begin
                     L := R;
                     R := 2 * R;
                    if N >= R then
                      Res := Res + (R-1)*R;
                   end
                  else
                   begin
                     L := N;
                     R := 2 * R;
                   end;
                 for I := 3 to L do begin
                   if (R mod I) = 0 then
                     Res := Res + (I-1)*I;
                 end;
                 write(Res div 2);
end.Поза форумом

program Pool;
var XMax, YMax, X1, Y1, X2, Y2, MinL, L : real;
procedure Len(X1, Y1, X2, Y2 : real);
begin
         L := sqrt(sqr(X1-X2)+sqr(Y1-Y2));
        if L < MinL then
          MinL := L;
end;
begin
           read(XMax, YMax, X1, Y1, X2, Y2);
           MinL := 5000;
           Len(X1, Y1, -1* X2, Y2);
           Len(X1, Y1, X2, YMax + (YMax-Y2));
           Len(X1, Y1, XMax + (XMax - X2), Y2);
           Len(X1, Y1, X2, -1*Y2);
           write(MinL);
end.program Failure;
var T1b, T1e, T2b, T2e, V1, V2, L1, L2, X1, Y1, X2, Y2, B, E : real;
    I, T : integer;
begin
                 read(T);
                for I := 1 to T do begin
                   read(V1, V2, L1, L2, X1, Y1, X2, Y2);
                  if X1 = 0 then
                   begin
                     T1b := Y1 / V1;
                     T1e := (Y1+L1) / V1;
                     T2b := X2 / V2;
                     T2e := (X2+L2) / V2;
                   end
                  else
                   begin
                     T1b := X1 / V1;
                     T1e := (X1+L1) / V1;
                     T2b := Y2 / V2;
                     T2e := (Y2+L2) / V2;
                   end;             
                   if T1b > T2B then
                    begin
                      B := T1b;
                      E := T1e;
                      T1b := T2b;
                      T1e := T2e;
                      T2b := B;
                      T2e := E;
                    end;
                   if T2b < T1e then
                     write(1)
                   else
                     write(0);
                end;
end.program Dictionary;
Type Mas1 = Array[1..12] of boolean;
var N, K, NF, I, J, P, Q, M : longint;
A : mas1;
S : string[12];
begin
                    read(N, K);
                    FillChar(A, SizeOf(A), False);
                    S := '';
                    Nf := 1;
                   for I := 2 to N-1 do
                     Nf := Nf * I;
                   for I := N-1 downto 1 do begin
                     P := K div Nf;
                     Q := K mod Nf;
                    if Q <> 0 then
                      P := P + 1;
                     if P > (I+1) then
                       P := P mod (I+1);
                      if P = 0 then
                        P := (I + 1);
                       M := 0;
                     for J := 1 to N do
                       if A[J] = False then
                        begin
                          inc(M);
                         if M = P then
                          begin
                           A[J] := True;
                           S := S + chr(J+96);
                           break;
                          end;
                        end;
                      Nf := Nf div I;
                   end;
                   for I := 1 to N do
                    if A[i] = False then
                      S := S + chr(I+96);
                   write(S);
end.program Area;
var X1b, Y1b, X1e, Y1e, X2b, Y2b, X2e, Y2e, X, Y, T, I : integer;
procedure Zamina(var A, B : integer);
var C : integer;
begin
               C := A;
               A := B;
               B := C;
end;
procedure BigZamina(var A1, B1, A2, B2 : integer);
var C : integer;
begin
              C := A1;
              A1 := A2;
              A2 := C;
              C := B1;
              B1 := B2;
              B2 := C;
end;
begin
                          read(T);
                        for I := 1 to T do begin
                           read(X1b, Y1b, X1e, Y1e, X2b, Y2b, X2e, Y2e);
                          if X1b > X1e then
                            Zamina(X1b, X1e);
                          if Y1b > Y1e then
                            Zamina(Y1b, Y1e);
                          if X2b > X2e then
                            Zamina(X2b, X2e);
                          if Y2b > Y2e then
                            Zamina(Y2b, Y2e);
                          if X1b > X2b then
                            BigZamina(X1b, X1e, X2b, X2e);
                          if Y1b > Y2b then
                            BigZamina(Y1b, Y1e, Y2b, Y2e);
                          if X2b < X1e then
                            X := 2
                          else
                           if X2b = X1e then
                             X := 1
                           else
                             X := 0;
                          if Y2b < Y1e then
                            Y := 2
                          else
                           if Y2b = Y1e then
                             Y := 1
                           else
                             Y := 0;
                          if (X = 1) and (Y = 1) then
                            write(1)
                          else
                           if ((X = 1) and (Y = 2)) or ((Y = 1) and (X = 2)) then
                             write(2)
                           else
                            if (X = 2) and (Y = 2) then
                              write(3)
                            else
                              write(0)
                        end;
end.Поза форумом

1. failure
program Failure;
{$APPTYPE CONSOLE}
var x1,x2,l1,l2,y1,y2,v1,v2,d1,d2:extended;
n,t:integer;
f:boolean;
begin
read(t);
for n:=1 to t do
   begin
  read(v1,v2,l1,l2,x1,y1,x2,y2);
  f:=false;
  d1:=x1+y1;
  d2:=x2+y2;
   if (v1<>0) and (v2<>0) then begin
   f:=(((d1+l1)/v1<=y2/v2) or ((d2+l2)/v2<=x1/v1));
    if f then write(0)
    else write(1);
   end
  else write(0);
  end;
end.2.pool
{$A+,B-,C+,D+,E+,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}
program Pool;
{$APPTYPE CONSOLE}
var x1,x2,y1,y2,xmax,ymax,lmin,l,ass:extended;
fout:text;
begin
read(xmax,ymax,x1,y1,x2,y2);
lmin:=((x1-x2)*(x1-x2)+(y1+y2)*(y1+y2));
l:=((x1-x2)*(x1-x2)+(ymax+ymax-y2-y1)*(ymax+ymax-y2-y1));
if l<lmin then lmin:=l;
l:=((y1-y2)*(y1-y2)+(xmax+xmax-x2-x1)*(xmax+xmax-x2-x1));
if l<lmin then lmin:=l;
l:=((y1-y2)*(y1-y2)+(x1+x2)*(x1+x2));
if l<lmin then lmin:=l;
writeln(sqrt(lmin));
end.3.supernet
program SuperNet; var n,i,r,ans:longint; begin read(r,n); ans:=0; r:=r shl 1; for i:=3 to n do if (r mod i=0) then ans:=ans+(i*(i-1)) shr 1; writeln(ans); end.
4.area
{$A+,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}
program Area;
var x1,i,t1,x2,x3,x4,y1,y2,y3,y4:integer;
f:byte;
{$APPTYPE CONSOLE}
procedure snap(var x,y:integer);
var t:integer;
begin
t:=x;
x:=y;
y:=t;
end;
begin
read(t1);
for i:=1 to t1 do begin
read(x1,y1,x2,y2,x3,y3,x4,y4);
if x1>x2 then snap(x1,x2);
if y1>y2 then snap(y1,y2);
if x3>x4 then snap(x3,x4);
if y3>y4 then snap(y3,y4);
if x1>x3 then begin
              snap(x1,x3);
              snap(x2,x4);
              snap(y1,y3);
              snap(y2,y4);
              end;
if (y3>y2) or (x3>x2) or (y1>y4) then f:=0 {1}
   else if ((x2=x3) and (y2=y3)) or ((y1=y4) and (x2=x3)) then f:=1 {5}
     else if ((y3=y2)) or ((y1=y4)) or (x2=x3) then f:=2 {7}
        else f:=3;
 write(f);
 end;
 end.5.dicionary
program dictionary;
var n,m,i,ans,j:longint;
a:array[0..14]of byte;
{$APPTYPE CONSOLE}
procedure P(N : longint; K : longint; var A : array of byte);
var
    Temp : Integer;
    SelNum : Integer;
    I : Integer;
    J : Integer;
    F : Integer;
begin
    K := K-1;
    F := 1;
    I:=1;
    while I<=N do
    begin
        A[i] := I;
        F := F*I;
        Inc(I);
    end;
    I:=1;
    while I<=N-1 do
    begin
        F := F div (N+1-I);
        SelNum := I+K div F;
        Temp := A[SelNum];
        J:=SelNum;
        while J>=I+1 do
        begin
            A[J] := A[J-1];
            Dec(J);
        end;
        A[i] := Temp;
        K := K mod F;
        Inc(I);
    end;
end;
begin
readln(n,m);
p(n,m,a);
for i:=1 to n do
write(char(ord('a')-1+a[i]));
end.Відредаговано Dark_Dimius (2006-10-27 23:27:19)
Поза форумом
SuperNet:
Program SuperNet;
{$AppType Console}
var
  r,n,k,i:longint;
begin
  readln(r,n);
  k:=0;
  for i:=3 to n do
    if (2*r)mod i=0
      then k:=k+i*(i-1)div 2;
  writeln(k)
end.Поза форумом
Dictionary:
Program Dictionary;
{$AppType Console}
const
  f:array[1..11]of longint=(1,2,6,24,120,720,5040,40320,
                            362880,3628800,39916800);
  a:string[12]='abcdefghijkl';
var
  n,k,b,i:longint;
  l:array[1..12]of boolean;
procedure writel(b:integer);
  var c,i:integer;
  begin
    i:=0;c:=0;
    while c<>b do begin
      inc(i);
      while not l[i] do inc(i);
      inc(c)
    end;
    write(a[i]);
    l[i]:=false;
  end;
begin
  readln(n,k);
  fillchar(l,sizeof(l),1);
  for i:=n-1 downto 1 do begin
    b:=k div f[i];
    if k mod f[i]<>0 then inc(b);
    writel(b);
    k:=k-(b-1)*f[i]
  end;
  writel(1);writeln
end.Поза форумом
Area:
Program Area;
{$AppType Console}
var
  s,k,t,nt:longint;
  xu1,yu1,xu2,yu2,xp1,yp1,xp2,yp2:longint;
begin
  read(nt);
  for t:=1 to nt do begin
    read(xu1,yu1,xu2,yu2,xp1,yp1,xp2,yp2);
    s:=abs(xu1+xu2-xp1-xp2)-abs(xu1-xu2)-abs(xp1-xp2);
    if s>0 then k:=0
      else if s=0 then k:=1
        else k:=2;
    s:=abs(yu1+yu2-yp1-yp2)-abs(yu1-yu2)-abs(yp1-yp2);
    if s>0 then k:=0
      else if s=0 then k:=k*1
        else k:=k*2;
    if k=4 then write(3) else write(k)
  end;
  writeln
end.Поза форумом
Pool:
Program Pool;
{$AppType Console}
var
  xm,ym,x1,y1,x2,y2,d,c:real;
begin
  readln(xm,ym,x1,y1,x2,y2);
  if((x1<>x2)or(y1>y2))and(y2<>ym)then begin
    d:=sqrt(sqr(2*ym-y1-y2)+sqr(x1-x2));
  end;
  if((x1<>x2)or(y2>y1))and(y2<>0)then begin
    c:=sqrt(sqr(y1+y2)+sqr(x1-x2));
    if c<d then d:=c
  end;
  if((y1<>y2)or(x1>x2))and(x2<>xm)then begin
    c:=sqrt(sqr(2*xm-x1-x2)+sqr(y1-y2));
    if c<d then d:=c
  end;
  if((y1<>y2)or(x2>x1))and(x2<>0)then begin
    c:=sqrt(sqr(x1+x2)+sqr(y1-y2));
    if c<d then d:=c
  end;
  writeln(d)
end.Відредаговано MAA (2006-10-28 00:30:16)
Поза форумом
Failure:
Program Failure;
{$AppType Console}
var
  v1,v2,l1,l2,x1,y1,x2,y2:real;
  t,nt:integer;
begin
  read(nt);
  for t:=1 to nt do begin
    read(v1,v2,l1,l2,x1,y1,x2,y2);
    x1:=x1+y1;x2:=x2+y2;
    y1:=x1+l1;y2:=x2+l2;
    x1:=x1/v1;x2:=x2/v2;
    y1:=y1/v1;y2:=y2/v2;
    if((x2>=x1)and(x2>=y1)and(y2>=x1)and(y2>=y1))or
      ((x2<=x1)and(x2<=y1)and(y2<=x1)and(y2<=y1))
      then write(0)
      else write(1)
  end;
  writeln;
end.Поза форумом

Supernet:
var r,n,i:integer; s,k:longint; begin read(r,n); s:=0; k:=3; i:=3; r:=r*2; while (i<=n) and (i<=r) do begin if r mod i=0 then inc(s,k); inc(k,i); inc(i); end; writeln(s); end.
Поза форумом
Supernet
   
var r,n,i:integer; sum:longint; begin sum:=0; read(r,n); for i:=3 to n do if (2*r) mod (i) = 0 then sum:=sum+(i*(i-1))div 2; writeln(sum); end.
Area
var
 n,i:integer;
 yx1,yx2,yy1,yy2,px1,px2,py1,py2,tpx,tpy:integer;
procedure up(var x,y:integer);
          var t:integer;
          begin
           if x>y then begin
              t:=x;
              x:=y;
              y:=t;
           end;
          end;
begin
 read(n);
 for i:=1 to n do begin
  read(yx1,yy1,yx2,yy2,px1,py1,px2,py2);
  up(yx1,yx2);
  up(yy1,yy2);
  up(px1,px2);
  up(py1,py2);
  if (yx1=px2)or(yx2=px1) then tpx:=1
  else if (yx1>px2)or(yx2<px1) then tpx:=0 else tpx:=2;
  if (yy1=py2)or(yy2=py1) then tpy:=1
  else if (yy1>py2)or(yy2<py1) then tpy:=0 else tpy:=2;
  tpx:=tpx*tpy;
  if tpx=0 then write(0);
  if tpx=1 then write(1);
  if tpx=2 then write(2);
  if tpx=4 then write(3);
 end;
end.Відредаговано Ivan (2006-10-28 10:00:20)
Поза форумом

Казалось уже всё проверено и 100 баллов гарантированы... Но нет, файлуре (самая простая задача) - 7 баллов! :'( Утешает одно: остальные по 20 и итог - 87. ЗЫ - мои решения www.roso.nm.ru/down/net2006.zip
Поза форумом

помогите найти ошибку, я не нашел и 3 человека тоже ее не видят(уже 7)
program Failure;
{$APPTYPE CONSOLE}
var x1,x2,l1,l2,y1,y2,v1,v2,d1,d2:double;
n,t:integer;
f:boolean;
begin
read(t);
for n:=1 to t do
   begin
  read(v1,v2,l1,l2,x1,y1,x2,y2);
  f:=false;
  d1:=x1+y1;
  d2:=x2+y2;
   if (v1<>0) and (v2<>0) then begin
   f:=(((d1+l1)*v2<=y2*v1) or ((d2+l2)*v1<=x1*v2));
    if f then write(0)
    else write(1);
   end
  else write(0);
  end;
end.Відредаговано Dark_Dimius (2006-10-28 14:20:51)
Поза форумом

Area
#include <math.h>
#include <iostream>
using std::cin;
using std::cout;
int main() {
    
    int T;
    int x1,x2,y1,y2, x3,y3,x4,y4;
    int cnt,i;
    
    cin>>T;
    
    for (i = 1; i<=T; i++) {
        cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
        
        if (x1>x2) {x1 = x1+x2; x2 = x1-x2; x1 = x1-x2;}
        if (y1>y2) {y1 = y1+y2; y2 = y1-y2; y1 = y1-y2;}
        if (x3>x4) {x3 = x3+x4; x4 = x3-x4; x3 = x3-x4;}
        if (y3>y4) {y3 = y3+y4; y4 = y3-y4; y3 = y3-y4;}
          
        if (x2<x3 || x4<x1 || y2<y3 || y4<y1) {cnt = 0;}        
        else if ((y1==y4 || y2==y3) && (x1==x4 || x2==x3)) {cnt = 1;}        
        else if (y1==y4 || y2==y3 || x1==x4 || x2==x3) {cnt = 2;}
        else {cnt = 3;} 
  
         cout<<cnt;    
    } 
}
Поза форумом

Rybak написав:
f:=(((d1+l1)*v2<=y2*v1) or ((d2+l2)*v1<=x1*v2));
замени на
f:=(((d1+l1)*v2<=d2*v1) or ((d2+l2)*v1<=d1*v2));
большое спасибо!!!(жаль что сам не заметил - потерял 8 баллов)
Відредаговано Dark_Dimius (2006-10-28 18:44:57)
Поза форумом

Failure
#include <math.h>
#include <iostream>
using std::cin;
using std::cout;
int main() {
    
    int T;
    double V1,V2, x1,x2,y1,y2, L1,L2;
    double T1,T2, dT1,dT2;
    int cnt,i;
    
    cin>>T;
    
    for (i = 1; i<=T; i++) {
        cin>>V1>>V2>>L1>>L2>>x1>>y1>>x2>>y2;
        if (V1==0 || V2==0){
            cnt = 0;
            cout<<cnt;            
        } 
        else {
             T1 = sqrt(x1*x1 + y1*y1)/V1; 
             T2 = sqrt(x2*x2 + y2*y2)/V2;
             dT1 = T1 + L1/V1; 
             dT2 = T2 + L2/V2;
        
             (T1>=dT2 || T2>=dT1)?(cnt = 0):(cnt = 1);
             cout<<cnt;
          }
    } 
}
Поза форумом
SUPERNET
#include<iostream>
using namespace std;
int r,n;
long long res;
main(){
    cin>>r>>n;
    for(r<<=1;n>2;--n)
        res+=(r%n?0:n*(n-1)>>1);
    cout<<res;
    return 0;
}POOL
#include<iostream>
#include<cmath>
using namespace std;
double res=1e100;
inline double sqr(double x){return x*x;}
inline void dist(double x1,double y1,double x2,double y2){
    if(fabs(x2-x1)>1e-6){
        double r=sqr(x2-x1)+sqr(y1+y2);
        if(r<res)res=r;
    }
}
main(){
    double xmax,ymax,x1,y1,x2,y2;
    cin>>xmax>>ymax>>x1>>y1>>x2>>y2;
    dist(x1,y1,x2,y2);
    dist(y1,x1,y2,x2);
    dist(x1,ymax-y1,x2,ymax-y2);
    dist(y1,xmax-x1,y2,xmax-x2);
    cout<<sqrt(res);
    return 0;
}FAILURE
#include<iostream>
inline double min(double x,double y){return x<y?x:y;}
inline double max(double x,double y){return x>y?x:y;}
using namespace std;
main(){
    int t;double v1,v2,l1,l2,x1,y1,x2,y2;
    for(cin>>t;t;--t){
        cin>>v1>>v2>>l1>>l2>>x1>>y1>>x2>>y2;
        x1+=y1,x2+=y2;
        cout<<(min((x1+l1)*v2,(x2+l2)*v1)-max(x1*v2,x2*v1)>1e-8?'1':'0');
    }
    return 0;
}DICTIONARY
#include<iostream>
using namespace std;
int n,k,i,f=1;
char abc[13],*j;
main(){
    cin>>n>>k;
    for(i=0;i<n;f*=(++i))
        abc[i]=i+'a';
    for(--k;i;--i,k%=f,*j=0){
        cout<<*(j=abc+k/(f/=i));
        for(;j[1];++j)*j=j[1];
    }
    return 0;
}AREA
#include<iostream>
using namespace std;
#define srt(x,y)    if(x>y)x^=y^=x^=y
main(){
    int t,x1,y1,x2,y2,x3,y3,x4,y4;
    for(cin>>t;t;--t){
        cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
        srt(x1,x2);srt(y1,y2);
        srt(x3,x4);srt(y3,y4);
        if(x3>x1)x1=x3;
        if(x4<x2)x2=x4;
        if(y3>y1)y1=y3;
        if(y4<y2)y2=y4;
        if(x1>x2||y1>y2)cout<<'0';
        else if(x1==x2 && y1==y2)cout<<'1';
        else if(x1==x2 || y1==y2)cout<<'2';
        else cout<<'3';
    }
    return 0;
}Поза форумом

FAILURE
#include<stdio.h>
#define CRASH 1
#define ALLRIGHT 0
main()
{
int T,i,j;
float mas[10][10];
float t1_1,t1_2,t2_1,t2_2,s1,s2;
        scanf("%d",&T);
        for(j=1;j<=T;j++)
        for(i=1;i<=8;i++)
        scanf("%f",&mas[i][j]);
        for(j=1;j<=T;j++)
          {
          s1=(mas[5][j]>mas[6][j])?mas[5][j]:mas[6][j];
          s2=(mas[7][j]>mas[8][j])?mas[7][j]:mas[8][j];
          t1_1=s1/mas[1][j];
          t1_2=(s1+mas[3][j])/mas[1][j];
          t2_1=s2/mas[2][j];
          t2_2=(s2+mas[4][j])/mas[2][j];
          if((t1_1>=t2_1)&&(t1_1<t2_2)||(t2_1>=t1_1)&&(t2_1<t1_2))
          printf("%d",CRASH);
          else
          printf("%d",ALLRIGHT);
          }
}Поза форумом

AREA
#include<stdio.h>
#define NO 0
#define POINT 1
#define LINE 2
#define RECTANGLE 3
main()
{
int T,i,j,x1_1,y1_1,x1_2,y1_2,x2_1,y2_1,x2_2,y2_2;
int mas[100][100];
    scanf("%d",&T);
    for(i=1;i<=T;i++)
      for(j=1;j<=8;j++)
      scanf("%d",&mas[i][j]);
    for(i=1;i<=T;i++)
    {
    x1_1=(mas[i][1]<=mas[i][3])?mas[i][1]:mas[i][3];
    y1_1=(mas[i][2]<=mas[i][4])?mas[i][2]:mas[i][4];
    x1_2=(mas[i][1]>=mas[i][3])?mas[i][1]:mas[i][3];
    y1_2=(mas[i][2]>=mas[i][4])?mas[i][2]:mas[i][4];
    x2_1=(mas[i][5]<=mas[i][7])?mas[i][5]:mas[i][7];
    y2_1=(mas[i][6]<=mas[i][8])?mas[i][6]:mas[i][8];
    x2_2=(mas[i][5]>=mas[i][7])?mas[i][5]:mas[i][7];
    y2_2=(mas[i][6]>=mas[i][8])?mas[i][6]:mas[i][8];
    if(((x1_1>x2_2)||(x1_2<x2_1))||((y1_1>y2_2)||(y1_2<y2_1)))
    printf("%d",NO);
    else
    if(((x1_1==x2_2)&&(y1_1==y2_2))||((x1_2==x2_1)&&(y1_1==y2_2))
    ||((x1_1==x2_2)&&(y1_2==y2_1))||((x1_2==x2_1)&&(y1_2==y2_1)))
    printf("%d",POINT);
    else
    if((((x1_1<=x2_1)&&(x2_1<x1_2))&&((y1_1==y2_2)||(y1_2==y2_1)))
    ||(((x1_1<x2_2)&&(x2_2<=x1_2))&&((y1_1==y2_2)||(y1_2==y2_1)))
    ||(((y1_1<=y2_1)&&(y2_1<y1_2))&&((x1_1==x2_2)||(x1_2==x2_1)))
    ||(((y1_1<y2_2)&&(y2_2<=y1_2))&&((x1_1==x2_2)||(x1_2==x2_1))))
    printf("%d",LINE);
    else
    printf("%d",RECTANGLE);
    }
}Поза форумом

POOL
#include<stdio.h>
#include<math.h>
main()
{
float Xmax,Ymax,x1,y1,x2,y2,S,stemp;
       scanf("%f %f %f %f %f %f",&Xmax,&Ymax,&x1,&y1,&x2,&y2);
       S=sqrt((y1-y2)*(y1-y2)+(2*Xmax-x1-x2)*(2*Xmax-x1-x2));
       stemp=sqrt((x2-x1)*(x2-x1)+(y1+y2)*(y1+y2));
       S=(S>stemp)?stemp:S;
       stemp=sqrt((x1+x2)*(x1+x2)+(y1-y2)*(y1-y2));
       S=(S>stemp)?stemp:S;
       stemp=sqrt((x1-x2)*(x1-x2)+(2*Ymax-y1-y2)*(2*Ymax-y1-y2));
       S=(S>stemp)?stemp:S;
       printf("%e",S);
}Поза форумом
AREA
#include <iostream>
using namespace std;
int sp(int x1,register int x2,register int x3,register int x4)
{
  if(x1 > x2)
  {
    int t = x1;
    x1 = x2;
    x2 = t;
  }
  if(x3 > x4)
  {
    int t = x3;
    x3 = x4;
    x4 = t;
  }
  register int kol = -1;
  for(register int x = x1;x <= x2;++x)
  {
     if(x3 <= x && x <= x4)
     {
       ++kol;
       if(kol >= 1)
         break;
     }
  }
  return kol;
}
int main(int argc, char* argv[])
{
  int T;
  cin >> T;
  int x1,y1,x2,y2,x3,y3,x4,y4;
  for(int i = 0;i < T;++i)
  {
    int l1,l2;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    l1 = sp(x1,x2,x3,x4);
    l2 = sp(y1,y2,y3,y4);
    if(l1 == -1 || l2 == -1)
      cout<<0;
    else
      if(l1 == 0 && l2 == 0)
        cout<<1;
      else
        if(l1 == 0 || l2 == 0)
          cout<<2;
        else
          cout<<3;
  }
  return 0;
}
//---------------------------------------------------------------------------
Поза форумом