

Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
Bài 1:
uses crt;
var s: ansistring;
i, res, cnt: longint;
c: boolean;
begin
clrscr;
readln(s);
for i:=1 to length(s) do begin
if s[i] = '1' then begin
if c then inc(cnt) else inc(res);
end else begin
if cnt mod 2 = 0 then inc(res);
cnt:=0; c:=true;
end;
end;
if c and (cnt mod 2 = 1) then dec(res);
writeln(res);
readln;
end.
Bài 2:
uses crt;
type int = longint;
var i, n, x: int;
a: array[0..1000000] of int;
res: int64;
begin
clrscr;
readln(n);
for i:=1 to n do begin
read(x); inc(res, a[x]); inc(a[x]);
end;
writeln(res);
readln;
end.
Hãy giúp mọi người biết câu trả lời này thế nào?

Bài 1:
uses crt;
var s: ansistring;
i, res, cnt: longint;
c: boolean;
begin
clrscr;
readln(s);
for i:=1 to length(s) do begin
if s[i] = '1' then begin
if c then cnt:=cnt+1 else res:=res+1;
end
else
begin
if cnt mod 2 = 0 then res:=res+1;
cnt:=0; c:=true;
end;
end;
if c and (cnt mod 2 = 1) then res:=res-1;
writeln(res);
readln;
end.
Bài 2:
uses crt;
type int = longint;
var i, n, x: int;
a: array[0..1000000] of int;
res: int64;
begin
clrscr;
readln(n);
for i:=1 to n do begin
read(x); inc(res, a[x]); inc(a[x]);
end;
writeln(res);
readln;
end.
Hãy giúp mọi người biết câu trả lời này thế nào?

Bảng tin
20
237
9
helpp gap
20
237
9
help với
20
237
9
https://hoidap247.com/cau-hoi/3884110
20
237
9
https://hoidap247.com/cau-hoi/3891851 pls
20
237
9
......................
20
237
9
https://hoidap247.com/cau-hoi/3933508
20
237
9
https://hoidap247.com/cau-hoi/3984877 helpppp
0
6
0
Thần đồng đổi thành c++ đc k ạ !!