Головна
Оргкомітет та журі
Реєстрація
Таблиця учасників
Тренувальний тур
Розв'язок тренувального туру
Перший тур
Другий тур
Розв'язок 1 туру


Програмний код розв'язку завдання першого туру з перелiком тестів

program vio1;
Const MaxDig=300;
Osn=10000;
sp=0;
Type Tlong=Array[0..MaxDig] of Integer;
Var A,B,C:Tlong;

Procedure ReadLong(Var A:Tlong);
Var ch:char;i:Integer;
Begin
FillChar(A,SizeOf(A) , 0) ;
Read(ch);
While Not(ch In ['0'..'9']) Do Read(ch);
While ch In ['0'..'9'] Do Begin
For i:=A[0] DownTo 1 Do Begin
A[i+1]:=A[i+1]+(LongInt(A[i])*10) Div Osn;
A[i]:=(LongInt(A[i])*10) Mod Osn;
End;
A[1]:=A[1]+Ord(ch)-Ord('0' ) ;
If A[A[0]+1]>0 Then Inc(A[0]);
Read(ch) ;
End;
End;


Procedure WriteLong(Const A:Tlong);
Var ls,s:String;
i:Integer;
Begin
Str (Osn Div 10,ls) ;
Write(A[A[0]]);
For i:=A[0]-1 DownTo 1 Do Begin
Str(A[i],s) ;
While Length(s) Write (s) ;
End;
Writeln;
End;


Procedure Sub (Var A: TLong;Const B: TLong;
Const sp: Integer);
Var i,j: Integer;
Begin
For i:=1 To B[0] Do Begin Dec(A[i+sp], B[i]);
j:=i;{*}
while (A[j+sp]<0) and (j<=A[0]) Do
Begin{*}
Inc(A[j+sp], Osn);
Dec(A[j+sp+1]);Inc(j) ;
end;
End;

i:=A [ 0 ] ;
While (i>1) And (A[i]=0) Do Dec(i);
A[0]:=i;
End;
function pl(a:TLong):boolean;
Var i: Integer;
s,n:integer;
begin
s:=0;
for i:=1 to a[0] do
begin
n:=a[i];
while n>0 do begin
s:=s+n mod 10;
n:=n div 10;
end;
end;
if s mod 3<>0 then pl:=true else pl:=false;
end;



Begin
Assign(Input,'Input3.txt'); Reset(Input);
ReadLong(A);
ReadLong(B);
Close (Input) ;
SUB(B,A,SP);
Assign(Output,'Output.txt');
Rewrite(Output);
if pl(B) then writeln(output,'Yes') else writeln(output,'No');
WriteLong(B);
Close(Output);
End.

Тест 1 (5 балів)
input.txt

7587
34389

output.txt

No
26802

Тест 2 (10 балів)
input.txt

564535753
789890000

output.txt

Yes
225354247

Тест 3 (20 балів)
input.txt

5555555555555555555555555555555
9999999999999999999999999999999

output.txt

Yes
4444444444444444444444444444444

Тест 4 (20 балів)
input.txt

545784546563478535649358934879565465789689568578476
4568954689058790654789098089068907489056897568978965897890673824523789

output.txt

No
4568954689058790654243313542505428953407538634099400432100984255945313

Тест 5 (20 балів)
input.txt

5789234654690580976905789068904890779080708788690768900979035789784578346564562531424556234
5782347895792657867587896523477623426543452345234563245656234423564562345624234523454523452344523453254234256456562345623452356435

output.txt

Yes
5782347895792657867587896523477623426537663110579872664679328634495657454845153814665832683443544417464449678109997783092027800201

Тест 6 (25 балів)
input.txt

5345345745368957856868546783422590239893290909909000000000000000000027423432763412341234321312351234123123412341233543123452312351256312352345624712347615347514576547457623116325456562345656234234823652312344366546356436536644699623999999999999999999999999999
10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001

output.txt

No
4654654254631042143131453216577409760106709090090999999999999999999972576567236587658765678687648765876876587658766456876547687648743687647654375287652384652485423452542376883674543437654343765765176347687655633453643563463355300376000000000000000000000000002