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.
mình ghi dư cái số 4 bên phần BAI7.INP nha mn
#include <bits/stdc++.h>
using namespace std;
long long a[1000],i,n,j;
bool kt;
int main()
{
freopen("nguyento.inp","r",stdin);
freopen("nguyento.out","w",stdout);
cin>>n;
for (i=1; i<=n; i++) cin>>a[i];
for (i=1; i<=n; i++)
if (a[i]>1)
{
kt=true;
for (j=2; j*j<=a[i]; j++)
if (a[i]%j==0) kt=false;
if (kt==true) cout<<a[i]<<" ";
}
return 0;
}
const fi='xsum1.inp';
fo='xsum1.out';
var f1,f2:text;
a:array[1..20000]of integer;
i,n,j,x,dem,k,m,t:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n,x);
for i:=1 to n do
read(f1,a[i]);
dem:=0;
for i:=1 to n do
for j:=1 to n do
begin
for k:=1 to n do
if (i<j) and (j<k) then
begin
t:=0;
for m:=i to k do
t:=t+a[m];
if t=x then inc(dem);
end;
end;
for i:=1 to n do
if x=a[i] then inc(dem);
writeln(f2,dem);
close(f1);
close(f2);
end.
program COST;
var n,m,s,dem:int64;a:
array[1..1000000] of int64;
i,j:longint;
begin
readln(n,m);
for i := 1 to n do read(a[i]);
dem := 0;
for i := 1 to n do
begin
s := 0;
for j := i to n do
begin
s := s+a[j];
if s <= m then
begin
inc(dem);
continue;
end
else if a[j] > m then break;
end;
end;
write(dem);
end.
uses crt;
var a:array[1..1000]of integer;
i,n,k,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
write('Nhap k='); readln(k);
for i:=1 to n do
if a[i]=k then
begin
writeln(i);
break;
end;
dem:=0;
for i:=1 to n do
if a[i]=k then inc(dem);
if dem>0 then writeln('Co ',dem,' phan tu bang ',k)
else writeln('Khong co phan tu nao bang ',k);
readln;
end.
Bài 1:
Program HOC24;
var i,n,d : byte;
t: integer;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,' : '); readln(a[i]);
end;
for i:=1 to n do if (a[i] mod 3=0) and (a[i] mod 5=0) then
begin
d:=d+1;
t:=t+a[i];
end;
writeln('Co ',d,' phan tu la boi cua 3 va 5');
write('Tong la: ',t);
readln
end.
Bài 2:
Program HOC24;
var i,n,k : byte;
begin
write('Nhap N: '); readln(n);
for i:=1 to n do
begin
write('Nhap phan tu thu ',i,' : '); readln(a[i]);
end;
write('Nhap k: '); readln(k);
for i:=1 to n do if a[i]=k then d:=d+1;
writeln('Co ',d,' phan tu bang ',k);
Write('Cac chi so do la: ');
for i:=1 to n do if a[i]=k then write(i,' ');
readln
end.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll i, j, n, a[1000005], dem = 0, m;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (i = 1; i <= n; i++)
{
cin >> a[i];
if (a[i] % 3 == 0)
{
n--;
i--;
}
}
for (i = 1; i <= n; i++)
{
cout << a[i] << " ";
}
cout<<endl;
for(i=1;i<=n;i++)
{
if(a[i]%5==0)
{
for(j=i;j<=n;j++)
{
a[j]=a[j+1];
}
n--;
i--;
}
}
for(i=1;i<=n;i++)
{
cout<<a[i]<<" ";
}
return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main(){
//freopen("dayso.inp","r",stdin);
//freopen("dayso.out","w",stdout);
int n,k;
cin>>n>>k;
int d,a;
int dem=0;
for (int i=1;i<=n;i++){cin >> a>>d;
if ((k-a)%d==0){dem++;}
}
cout<<dem;
}