Thứ Tư, 27 tháng 4, 2022

EQUA PASCAL

ar B:array[1..1000000] of boolean;
    i,k,x,y,z,d:longint;
Procedure sangnt;
Var  i,j,n:longint;
Begin
    fillchar(B,sizeof(B),true);
    B[1]:=false;
    For i:=2 to trunc(sqrt(1000000)) do
        If B[i]=true then
        begin
            j:=i*i;
            While j<=1000000 do
                begin
                    B[j]:=false;
                    j:=j+i;
                end;
        end;
end;
Begin
Assign(input,'EQUA.inp'); Reset(input);
Assign(output,'EQUA.out'); Rewrite(output);
sangnt; Readln(k); d:=0;
For x:=1 to k div 2 do
    for y:=1 to k div 2 do
        begin
            z:=k-x-y;
            If (z>0) and (x<=y) and (y<=z) then
            If (B[x]) and (B[y]) and (B[z]) then
            inc(d);
        end;
Writeln(d);
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.