Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
Input:
8
1 2 1 2 1 3 2
Output:
2
Như vầy à bn???
Mà nếu đúng thì Tick cho mk nha!Thank you nhìu!!
program FUTURE;
var n,dem:int64;
a:array[1..1000000] of int64;
i,j:longint;
kt:boolean;
function KTSNT(n:int64):boolean;
var i:longint;
kt:boolean;
begin
if n < 2 then KTSNT := false
else begin
kt := true;
for i:= 2 to trunc(sqrt(n)) do
if n mod i = 0 then
begin
kt := false;
break;
end;
if kt = true then KTSNT := true
else KTSNT := false;
end;
end;
BEGIN
readln(n);
for i := 1 to n do read(a[i]);
dem := 0;
for i := 1 to n do
begin
if KTSNT(a[i]) then continue
else if a[i] = 1 then continue
else
begin
kt := true;
for j := 2 to a[i]-1 do
if a[i] mod j = 0 then
if KTSNT(j) = false then
begin
kt := false;
break;
end;
end;
if kt = true then inc(dem);
end;
write(dem);
END.
a)
uses crt;
var a:array[1..20] of integer;
i,dem,t:integer;
begin
clrscr;
for i:=1 to 20 do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac phan tu chia het cho 3:');
for i:=1 to 20 do
if a[i] mod 3=0 then write(a[i]:4);
writeln;
dem:=0;
t:=0;
for i:=1 to 20 do
if a[i]>0 then
begin
dem:=dem+1;
t:=t+a[i];
end;
writeln('Trung binh cong cac phan tu nguyen duong la: ',t/dem:4:2);
readln;
end.
b)
uses crt;
var a:array[1..30] of integer;
i,dem,t:integer;
begin
clrscr;
for i:=1 to 30 do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
t:=0;
for i:=1 to 30 do
if a[i] mod 5=0 then
begin
dem:=dem+1;
t:=t+a[i];
end;
writeln('Trung binh cong cac phan tu chia het cho 5 la: ',t/dem:4:2);
readln;
end.
c)
uses crt;
var a:array[1..200]of integer;
i,n,max,min:integer;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (0<n) and (n<201);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
max:=a[1];
min:=a[1];
for i:=1 to n do
begin
if max<a[i] then max:=a[i];
if min>a[i] then min:=a[i];
end;
writeln('Phan tu lon nhat: ',max);
writeln('Phan tu nho nhat la: ',min);
readln;
end.
uses crt;
var a:array[2..1000000]of longint;
n,i,k,t,dem:longint;
begin
clrscr;
repeat
write('Nhap n='); readln(n);
until (1<n) and (n<=1000000);
for i:=2 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
t:=0;
dem:=0;
for i:=2 to n do
if a[i] mod k=0 then
begin
t:=t+a[i];
inc(dem);
end;
writeln('Tong cac so chia het cho ',k,' la: ',t);
writeln('So phan tu chia het cho ',k,' la: ',dem);
readln;
end.