K
Khách

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.

12 tháng 10 2018

var n,i,dem:longint;
a:array[1..1000000] of longint;
f:array[1..1000000] of boolean;
begin
assign(input,'text.inp'); reset(input);
assign(output,'text.out'); rewrite(output);
read(n); dem:=0;
for i:=1 to n do
begin
read(a[i]);
if a[i] mod 2=0 then
begin
f[i]:=true;
inc(dem);
end;
end;
writeln(dem);
for i:=1 to n do
if f[i] then write(a[i],' ');

end.

const fi='tong.inp';

fo='tong.out';

var f1,f2:text;

a:array[1..100]of integer;

n,i,t:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,n);

for i:=1 to n do 

  read(f1,a[i]);

t:=0;

for i:=1 to n do 

  t:=t+a[i];

writeln(f2,t);

close(f1);

close(f2);

end.

#include <bits/stdc++.h>

using namespace std;

string st;

int d,i,dem;

int main()

{

freopen("xau.inp","r",stdin);

freopen("xau.out","w",stdout);

cin>>st;

d=st.length();

dem=0;

for (i=0; i<=d-1; i++)

if (st[i]=='a') dem++;

cout<<dem;

return 0;

}

#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;

}

14 tháng 1

#include <bits/stdc++.h> #define N int(1e7) #define sp ios_base::sync_with_stdio(0),cin.tie(0),cin.tie(0),cout.tie(0); using namespace std; long long l,r,d=0,b[N]; bool a[N]; void sang() { a[1]=true; for(int i=2; i*i<=N; i++) if(a[i]==false) for(int j=i*i; j<=N; j+=i) a[j]=true; for(int i=1; i<=N; i++) { if(a[i]==false) d+=i; b[i]=d; } } int main() { sp sang(); int t; while(t--) { cin>>l>>r; cout<<b[r]-b[l-1]<<'\n'; } }