Thứ Ba, 3 tháng 5, 2022

DAUCHAN PASCAL

var n,i:longint;res:int64;
    s:ansistring;
    f:array[0..50005] of longint;

Procedure nhap;
var i:longint;
begin
        readln(s);
        n:=length(s);
end;

Procedure giai;
begin
        f[0]:=0;
        for i:=2 to n do
                if (s[i]='(') and (s[i-1]='(') then
                        f[i]:=f[i-1]+1
                else
                        f[i]:=f[i-1];
        for i:=2 to n do
                if (s[i]=')') and (s[i-1]=')') then
                        res:=res+f[i];
        writeln(res);
end;

begin
        assign(input,'dauchan.inp');reset(input);
        assign(output,'dauchan.out');rewrite(output);
        nhap;
        giai;
end.

Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.