Завдання №3
var
A,B,C: integer;
begin
Read (A,B,C);
if ((A>B) and
(A<C))or ((A<B) and (A>C)) then Write ('Петро')else
if ((B>A)and (B<C)) or ((B<A)and
(B>C)) then Write ('Іван')else
if ((C>A)and (C<B)) or ((C<A)and
(C>B)) then Write ('Сергій')else Write ('Cереднього немає');
end.
Задача 1(не все тесты идут)
var
x1,x2,y1,y2,N,i,par: integer;
Vluch,Tochno_vluch,n_vluch : integer;
input, output : Text;
A,B: array [1..100] of integer;
C:array [1..100] of integer;//попадание на линию
по 1
D:array [1..100] of integer;// попадание на ленту
по 1
begin
Assign (input,'Vvod.txt');
Reset (input);
Readln (input,x1,y1);
Readln (input,x2,y2);
if x1>x2 then //перестановка чисел по возрастанию
begin
par:=x1;
x1:=x2;
x2:=par;
end;
if y1>y2 then
begin
par:=y1;
y1:=y2;
y2:=par;
end;
Readln (input,N);
for i:=1 to N do
begin
readln (input,A[i],B[i]);
//Writeln (A[i],B[i]);
end;
for i:=1 to N do
begin
if (A[i]-x1)/(x2-x1)=
(B[i]-y1)/(y2-y1) then C[i]:=1 else C[i]:=0// проверка на попадание
на линию
end;
for i:=1 to N do
if (C[i]=1) and (A[i]<=x2)
and (A[I]>=x1) and (B[i]<=y2) and (B[I]>=y1) then
D[i]:=1 else D[i]:=0;//проверка на попадание на полоску
n_vluch:=0; // не попал
for i:=1 to N do
begin
if C[i]=0 then n_vluch:=n_vluch+1;// не попал
Tochno_vluch:=Tochno_vluch+D[i];//точно попал
end;
Vluch:=N-(n_vluch+Tochno_vluch);// просто попал
Assign (output,'vivod.txt');
Rewrite (output);
Write (output,Tochno_vluch,' ',Vluch,' ',n_vluch);
Close (input);
Close (output);
end.
Задання2
var
A,B , P,i,l,K: integer;
Par: integer;
C: array [1..100] of integer;
Pr: real;
input,output: Text;
begin
Assign (input,'Input.txt');
Reset (input);
Readln (input,A,B);
Read (input,P);
Close(input);
if A<B then
begin
Par:=A;
A:=B;
B:=Par;
end;
i:=1;
while (A>0) do// запись
элементов числа в масив
begin
C[I]:=A mod 10;
A:= A div 10;
//Write (C[i],' ');
I:=i+1;
end;
L:=i-1;
K:=0;
for i:=1 to l+1 do
begin
C[i]:=C[i]*B;
C[i]:=C[i]+K;//перенос разряда
if C[i] >= p then //проверка
на перенос разряда
begin
K:=(C[i]div P); //запись
после переноса
C[i]:= C[i] mod p;//определение
переносимых разрядов
end
else K:=0;
end;
//Writeln;
Assign (output,'output.txt');
Rewrite (output);
if C[L+1]>0 then L:=l+1;// проверка
на увеличение числа
for i:=l downto
1 do
Write (output,C[i]);
Writeln (output);
pr:=0;
for i:=1 to l do
begin
pr:=Pr+C[i]*Power(P,i-1); //степень
end;
Write(output,pr);
Close (output);
end.
Задача 2
program olimp_2016_2;
var
A,B, A1,B1,P,l: integer;
Pr: integer;
input,output: Text;
function step_p (a,p:integer ): integer;//функция перевода
числа А в систему по оснаванию Р
var
k:integer;
S: integer;
begin
S:=0;
K:=1;
while A>0 do
begin
S:=S+(A mod P)*K;
K:=K*10;
A:=A div P;
end;
step_p := S;
end;
function perevod10 (Pr,P:integer) : integer;//функция перевода
числа PR в 10 систему
var
K:integer;
S:integer;
begin
K:=1;
S:=0;
while (pr>0) do
begin
S:= S + (pr mod 10)*K;
Pr:= Pr div 10;
K:=K*p;
end;
perevod10:=s;
end;
begin
Assign (input,'Input.txt');
Reset (input);
Readln (input,A,B);
Read (input,P);
Close(input);
a1:=perevod10(A,p);
B1:=perevod10(B,P);
Pr:=a1*B1;
l:= step_p(Pr,p);
Assign (output,'output.txt');
Rewrite (output);
Writeln (output,l);
Write(output,pr);
Close (output);
end.
Задача2
program olimp_2016_2;
var
A,B, A1,B1,P,l: integer;
Pr: integer;
input,output: Text;
function step_p (a,p,p2:integer ): integer;//функция перевода числа А из системы Р всистему Р2
var
k:integer;
S: integer;
begin
S:=0;
K:=1;
while A>0 do
begin
S:=S+(A mod P2)*K;
K:=K*p;
A:=A div P2;
end;
step_p := S;
end;
begin
Assign (input,'Input.txt');
Reset (input);
Readln (input,A,B);
Read (input,P);
Close(input);
a1:=step_p(A,p,10);
B1:=step_p(B,P,10);
Pr:=a1*B1;
l:= step_p(Pr,10,P);
Assign (output,'output.txt');
Rewrite (output);
Writeln (output,l);
Write(output,pr);
Close (output);
end.
program olimp_2016_2;
var
A,B, A1,B1,P,l: integer;
Pr: integer;
input,output: Text;
function step_p (a,p,p2:integer ): integer;//функция перевода числа А из системы Р всистему Р2
var
k:integer;
S: integer;
begin
S:=0;
K:=1;
while A>0 do
begin
S:=S+(A mod P2)*K;
K:=K*p;
A:=A div P2;
end;
step_p := S;
end;
begin
Assign (input,'Input.txt');
Reset (input);
Readln (input,A,B);
Read (input,P);
Close(input);
a1:=step_p(A,p,10);
B1:=step_p(B,P,10);
Pr:=a1*B1;
l:= step_p(Pr,10,P);
Assign (output,'output.txt');
Rewrite (output);
Writeln (output,l);
Write(output,pr);
Close (output);
end.
Немає коментарів:
Дописати коментар