Задача A-Свято цукерок
Франчук Роман
#include <iostream>
using namespace std;
void trim0(string& s)
{
while(s.length()>1 && s[0]=='0')s.erase(0,1);
}
bool be(string a,string b)
{
if(a.length()>b.length())return true;
if(a.length()<b.length())return false;
for(int i=0;i<a.length();i++)if(a[i]>b[i])return true;else if(a[i]<b[i])return false;
return true;
}
int main()
{
string a,b,c;
cin>>a>>b>>c;
trim0(a);trim0(b);trim0(c);
if(be(a,b) && be(a,c))cout<<a<<'\n';else
if(be(b,c) && be(b,a))cout<<b<<'\n';else
cout<<c<<'\n';
return 0;
}
Задача B-Змійка
Савчук Владислав
Var s:array[0..4] of longint; fi,fo:text;
a:array[0..101,0..101] of longint;
n,m,i,j,kil:longint;
Begin
Assign(fi,'z2.dat');Reset(fi);
Assign(fo,'z2.sol');Rewrite(fo);
Readln(fi,n,m);
For i:=1 to n do Begin
For j:=1 to m do Begin Read(fi,a[i,j]); inc(kil,a[i,j]); end; Readln(fi); end;
For i:=1 to n do
For j:=1 to m do if a[i,j]=1 then inc(s[a[i+1,j]+a[i,j+1]+a[i,j-1]+a[i-1,j]]);
if kil=1 then Writeln(fo,'No') else
if (s[3]<>0) or (s[4]<>0) or (s[1]<>2) then Writeln(fo,'Yes') else Writeln(fo,'No');
writeln(fo,kil); Close(fi); Close(fo);
End.
Задача C-Командна гра
Нагін Сергій
var
l,x,n,i,j,k,ans:longint;
a,b:array[0..101,0..101]of 0..1;
begin
assign(input,'z3.dat');reset(input);
assign(output,'z3.sol');rewrite(output);
read(n);
fillchar(a,sizeof(a),0);
for i:=1 to n do
begin
read(h);
for j:=1 to l do
begin
read(x);
a[i,x]:=1;
end;
end;
fillchar(b,sizeof(b),0);
for i:=1 to n do
for j:=i+1 to n do
for k:=1 to 50 do
if (a[i,k]=1)and(a[j,k]=1) then
begin
b[i,j]:=1;
b[j,i]:=1;
break;
end;
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if i<>j then
if (b[i,k]=1)and(b[k,j]=1) then b[i,j]:=1;
ans:=1;
for i:=2 to n do
if b[1,i]=1 then ans:=ans+1;
writeln(ans);
close(input);close(output);
end.