PascalABC.NET 3.5.1
program D_contest;
type
TStat = record
nick: string;
wins, battles: integer;
proc: real;
end;
var
N, i, num: integer;
str: array of string;
stat: array of TStat;
function found(ni_ck: string): integer;
begin
found := -1;
for var e := 0 to Length(stat) - 1 do
if stat[e].nick = ni_ck then
found := e;
break;
v_pts, e_pts, l_e: integer;
F: textfile;
k: real;
s: string;
Assign(F, 'input.txt');
Reset(F);
readln(F, n);
SetLength(str, n);
SetLength(stat, 1);
for i := 0 to n - 1 do
readln(F, str[i]);
//get enemy_nick
nick := Copy(str[i], 1, Pos(' ', str[i]) - 1);
Delete(str[i], 1, Pos(' ', str[i]));
if (stat[0].nick <> '') then
num := found(nick);
if (num = -1) then //not found
l_e := Length(stat);
SetLength(stat, l_e + 1);
num := l_e;
stat[num].nick := nick;
end
else
stat[0].nick := nick;
stat[num].battles += 1;
//get Vania_points
v_pts := StrToInt(Copy(str[i], 1, Pos(' ', str[i])));
//get enemy_points
e_pts := StrToInt(str[i]);
if v_pts > e_pts Then
stat[num].wins += 1;
Close(F);
//вычисляю процент побед
for i := 0 to Length(stat) - 1 do
stat[i].proc := stat[i].wins / stat[i].battles;
//сортировка по процентам
for i := 0 to Length(stat) - 2 do
for var j := 0 to Length(stat) - i - 2 do
if stat[j].proc > stat[j + 1].proc then
k := stat[j].proc;
stat[j].proc := stat[j + 1].proc;
stat[j + 1].proc := k;
s := stat[j].nick;
stat[j].nick := stat[j + 1].nick;
stat[j + 1].nick := s;
//сортировка по алфавиту
if (stat[j].proc = stat[j + 1].proc) and (stat[j].nick > stat[j + 1].nick) then
writeln(Length(stat));
write(stat[i].nick, ' ');
writeln(stat[i].proc * 100:0:6);
end.
Объяснение:
Смотри код
Python 3.6
a = [int(i) for i in input().split()]
ab = abs(a[1] - a[2])
if ab > 180:
ab = 360 - ab
if ab % a[4] == 0:
x = ab // a[4]
else:
x = ab // a[4] + 1
if a[0] % a[3] == 0:
x += a[0] // a[3]
x += a[0] // a[3] + 1
print(x)
program who;
var a, b, ab, t: integer;
d, s, x: LongInt;
read(d, a, b, s, t);
ab := abs(a - b);
if ab > 180 then
ab := 360 - ab;
if ab mod t = 0 then
x := ab div t
x := ab div t + 1;
if d mod s = 0 then
x := x + d div s
x := x + d div s + 1;
write(x);
Думаю по коду поймешь
PascalABC.NET 3.5.1
program D_contest;
type
TStat = record
nick: string;
wins, battles: integer;
proc: real;
end;
var
N, i, num: integer;
str: array of string;
stat: array of TStat;
nick: string;
function found(ni_ck: string): integer;
begin
found := -1;
for var e := 0 to Length(stat) - 1 do
begin
if stat[e].nick = ni_ck then
begin
found := e;
break;
end;
end;
end;
var
v_pts, e_pts, l_e: integer;
F: textfile;
k: real;
s: string;
begin
Assign(F, 'input.txt');
Reset(F);
readln(F, n);
SetLength(str, n);
SetLength(stat, 1);
for i := 0 to n - 1 do
begin
readln(F, str[i]);
//get enemy_nick
nick := Copy(str[i], 1, Pos(' ', str[i]) - 1);
Delete(str[i], 1, Pos(' ', str[i]));
if (stat[0].nick <> '') then
begin
num := found(nick);
if (num = -1) then //not found
begin
l_e := Length(stat);
SetLength(stat, l_e + 1);
num := l_e;
stat[num].nick := nick;
end;
end
else
begin
stat[0].nick := nick;
end;
stat[num].battles += 1;
//get Vania_points
v_pts := StrToInt(Copy(str[i], 1, Pos(' ', str[i])));
Delete(str[i], 1, Pos(' ', str[i]));
//get enemy_points
e_pts := StrToInt(str[i]);
if v_pts > e_pts Then
stat[num].wins += 1;
end;
Close(F);
//вычисляю процент побед
for i := 0 to Length(stat) - 1 do
begin
stat[i].proc := stat[i].wins / stat[i].battles;
end;
//сортировка по процентам
for i := 0 to Length(stat) - 2 do
begin
for var j := 0 to Length(stat) - i - 2 do
begin
if stat[j].proc > stat[j + 1].proc then
begin
k := stat[j].proc;
stat[j].proc := stat[j + 1].proc;
stat[j + 1].proc := k;
s := stat[j].nick;
stat[j].nick := stat[j + 1].nick;
stat[j + 1].nick := s;
end;
end;
end;
//сортировка по алфавиту
for i := 0 to Length(stat) - 2 do
begin
for var j := 0 to Length(stat) - i - 2 do
begin
if (stat[j].proc = stat[j + 1].proc) and (stat[j].nick > stat[j + 1].nick) then
begin
k := stat[j].proc;
stat[j].proc := stat[j + 1].proc;
stat[j + 1].proc := k;
s := stat[j].nick;
stat[j].nick := stat[j + 1].nick;
stat[j + 1].nick := s;
end;
end;
end;
writeln(Length(stat));
for i := 0 to Length(stat) - 1 do
begin
write(stat[i].nick, ' ');
writeln(stat[i].proc * 100:0:6);
end;
end.
Объяснение:
Смотри код
Python 3.6
a = [int(i) for i in input().split()]
ab = abs(a[1] - a[2])
if ab > 180:
ab = 360 - ab
if ab % a[4] == 0:
x = ab // a[4]
else:
x = ab // a[4] + 1
if a[0] % a[3] == 0:
x += a[0] // a[3]
else:
x += a[0] // a[3] + 1
print(x)
PascalABC.NET 3.5.1
program who;
var a, b, ab, t: integer;
d, s, x: LongInt;
begin
read(d, a, b, s, t);
ab := abs(a - b);
if ab > 180 then
ab := 360 - ab;
if ab mod t = 0 then
x := ab div t
else
x := ab div t + 1;
if d mod s = 0 then
x := x + d div s
else
x := x + d div s + 1;
write(x);
end.
Объяснение:
Думаю по коду поймешь