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.
#include <bits/stdc++.h>
using namespace std;
long long i,n,dem;
int main()
{
cin>>n;
dem=0;
for (i=1; i<=n; i++)
{
int x=sqrt(i);
if (x*x==i)
{
dem++;
cout<<i<<" ";
}
}
cout<<endl;
cout<<dem;
return 0;
}
bạn ơi cái code này hơi chậm, bạn có thể sử dụng code này :)
#include <bits/stdc++.h>using namespace std;
int main(){
long long i;
cin >> i;
long long n = 1;
int counter = 0;
int additional = 3;
while (n<=i){
counter = counter +1;
n= n + additional;
additional = additional + 2;
}
cout << counter;
}
#include <bits/stdc++.h>
using namespace std;
long long n,i,dem,t;
int main()
{
cin>>n;
dem=0;
t=0;
for (i=1; i<=n; i++)
if (i%2==0)
{
t=t+i;
dem++;
}
cout<<t<<" "<<dem;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long n,i,x,dem1,dem2;
int main()
{
cin>>n;
dem1=0;
dem2=0;
for (i=1; i<=n; i++)
{
cin>>x;
if (x%2==0) dem1++;
else dem2++;
}
cout<<dem1<<" "<<dem2;
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,dem,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac so chan la: ');
dem:=0;
t:=0;
for i:=1 to n do
if a[i] mod 2=0 then
begin
write(a[i]:4);
t:=t+a[i];
inc(dem);
end;
writeln('Tong cac so chan la: ',t);
writeln('Trong day co ',dem,' so chan');
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long x,i,n,dem;
int main()
{
cin>>n;
dem=0;
for (i=1; i<=n; i++)
{
cin>>x;
if ((x%2==0) or (x%5==0)) dem++;
}
cout<<dem;
return 0;
}
uses crt;
var a:array[1..200]of integer;
i,n,tbc,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
writeln('Cac so duong chan la: ');
for i:=1 to n do
if (a[i] mod 2=0) and (a[i]>0) then write(a[i]:4);
writeln;
tbc:=0;
dem:=0;
for i:=1 to n do
if (-1000<=a[i]) and (a[i]<=1000) then
begin
tbc:=tbc+a[i];
dem:=dem+1;
end;
writeln('Trung binh cong cac phan tu co gia tri trong pham vi tu -1000 den 1000 la: ',tbc/dem:4:2);
readln;
end.
uses crt;
var a:array[1..250]of integer;
n,i,t,max,min:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
t:=0;
for i:=1 to n do
if a[i] mod 3=0 then t:=t+a[i];
writeln('Tong cac so la boi cua 3 la: ',t);
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('Gia tri lon nhat la: ',max);
writeln('Gia tri nho nhat la: ',min);
readln;
end.
uses crt;
var a:array[1..100]of integer;
i,n,tc,tl,t:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
tc:=0;
tl:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then tc:=tc+a[i]
else tl:=tl+a[i];
end;
writeln('Tong cac so chan la: ',tc);
writeln('Tong cac so le la: ',tl);
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln('Tong cua day so la: ',t);
readln;
end.
uses crt;
var a:array[1..1000]of integer;
i,n,dem1,dem2,t1,dem3,j,kt:integer;
begin
clrscr;
readln(n);
for i:=1 to n do
readln(a[i]);
dem1:=0;
dem2:=0;
t1:=0;
for i:=1 to n do
begin
if a[i] mod 2=0 then
begin
dem1:=dem1+1;
t1:=t1+a[i];
end;
else dem2:=dem2+1;
end;
dem3:=0;
for i:=1 to n do
if (a[i]>1) then
begin
kt:=0;
for j:=2 to trunc(sqrt(a[i])) do
if a[i] mod j=0 then kt:=1;
if kt=0 then dem3:=dem3+1;
end;
writeln(dem1, ' ',dem2);
writeln(t1);
writeln(dem3);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
long long n,i,dem,t;
int main()
{
cin>>n;
dem=0;
t=0;
for (i=1; i<=n; i++)
if (i%2==1)
{
t=t+i;
dem++;
}
cout<<t<<" "<<dem;
return 0;
}